|
|
|
@ -1,6 +1,11 @@
|
|
|
|
|
from model.data import Data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ComponentLexeme(Data):
|
|
|
|
|
# special value for last component that evaluates to True by default but is not
|
|
|
|
|
# exported to true
|
|
|
|
|
LAST_COMPONENT_SPACE = "last component does not have space"
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.other_attributes = {}
|
|
|
|
|
self.text = ""
|
|
|
|
@ -25,7 +30,7 @@ class ComponentLexeme(Data):
|
|
|
|
|
def isValid(self):
|
|
|
|
|
return len(self.text) > 0
|
|
|
|
|
|
|
|
|
|
def export(self, doc, is_multiword, last_component):
|
|
|
|
|
def export(self, doc):
|
|
|
|
|
if self.role is None:
|
|
|
|
|
return doc.createTextNode(self.text)
|
|
|
|
|
|
|
|
|
@ -33,9 +38,8 @@ class ComponentLexeme(Data):
|
|
|
|
|
result.setAttribute("role", self.role)
|
|
|
|
|
result.textContent = self.text
|
|
|
|
|
|
|
|
|
|
# no space is only allowed in in multiword examples that are not last component
|
|
|
|
|
if self.no_space is True and is_multiword and not last_component:
|
|
|
|
|
result.setAttribute("space", "false")
|
|
|
|
|
if self.no_space and self.no_space != self.LAST_COMPONENT_SPACE:
|
|
|
|
|
result.setAttribute("space", "false")
|
|
|
|
|
|
|
|
|
|
for key, value in self.other_attributes.items():
|
|
|
|
|
result.setAttribute(key, value)
|
|
|
|
|