added AddFirstElementToLabel class for structural element tokens
This commit is contained in:
parent
43b8fe5a32
commit
19e185f251
|
|
@ -5,6 +5,9 @@
|
|||
import os
|
||||
from itertools import zip_longest
|
||||
from collections import namedtuple
|
||||
|
||||
import rich
|
||||
|
||||
from bootstraparse.modules.error_mngr import CannotBeContainedError
|
||||
|
||||
import pyparsing as pp
|
||||
|
|
@ -80,6 +83,12 @@ class SemanticType:
|
|||
raise CannotBeContainedError(self)
|
||||
|
||||
|
||||
class AddFirstElementToLabel(SemanticType):
|
||||
def __init__(self, content):
|
||||
super().__init__(content)
|
||||
self.label += ":" + content[0]
|
||||
|
||||
|
||||
class ExplicitSemanticType(SemanticType):
|
||||
"""
|
||||
Explicit semantic type, the label is the only information we need.
|
||||
|
|
@ -202,12 +211,12 @@ class DisplayToken(SemanticType):
|
|||
label = "display"
|
||||
|
||||
|
||||
class StructuralElementStartToken(SemanticType):
|
||||
class StructuralElementStartToken(AddFirstElementToLabel, SemanticType):
|
||||
"""<<string"""
|
||||
label = "se:start"
|
||||
label = 'se:start'
|
||||
|
||||
|
||||
class StructuralElementEndToken(EncapsulatedSemanticType):
|
||||
class StructuralElementEndToken(AddFirstElementToLabel, EncapsulatedSemanticType):
|
||||
"""string>>"""
|
||||
label = "se:end"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue