add support for lexeme_id on comp #7

Merged
matic_t merged 1 commits from mt-additional-xml-shema-support into master 4 years ago

@ -11,7 +11,7 @@ class ComponentLexeme(Data):
self.text = "" self.text = ""
self.role = "" self.role = ""
self.no_space = False self.no_space = False
def import_xml(self, xml): def import_xml(self, xml):
if xml.nodeName == "#text": if xml.nodeName == "#text":
self.text = xml.data self.text = xml.data
@ -19,33 +19,31 @@ class ComponentLexeme(Data):
else: else:
self.text = xml.textContent self.text = xml.textContent
self.role = xml.getAttribute("role") self.role = xml.getAttribute("role")
if xml.hasAttribute("space"): if xml.hasAttribute("space"):
self.no_space = xml.getAttribute("space") == "false" self.no_space = xml.getAttribute("space") == "false"
for oth_attr in ["lexical_unit_lexeme_id", "slolex", "kol", "sloleks"]: for oth_attr in ["lexeme_id", "lexical_unit_lexeme_id", "slolex", "kol", "sloleks"]:
if xml.hasAttribute(oth_attr): if xml.hasAttribute(oth_attr):
self.other_attributes[oth_attr] = xml.getAttribute(oth_attr) self.other_attributes[oth_attr] = xml.getAttribute(oth_attr)
def isValid(self): def isValid(self):
return len(self.text) > 0 return len(self.text) > 0
def export(self, doc): def export(self, doc):
if self.role is None: if self.role is None:
return doc.createTextNode(self.text) return doc.createTextNode(self.text)
result = doc.createElement("comp") result = doc.createElement("comp")
result.setAttribute("role", self.role) result.setAttribute("role", self.role)
result.textContent = self.text result.textContent = self.text
if self.no_space and self.no_space != self.LAST_COMPONENT_SPACE: if self.no_space and self.no_space != self.LAST_COMPONENT_SPACE:
result.setAttribute("space", "false") result.setAttribute("space", "false")
for key, value in self.other_attributes.items(): for key, value in self.other_attributes.items():
result.setAttribute(key, value) result.setAttribute(key, value)
return result return result
def view_style(self): def view_style(self):
# no-space is handled in multiword-example directly # no-space is handled in multiword-example directly
result = ".comp-text" result = ".comp-text"
@ -53,8 +51,8 @@ class ComponentLexeme(Data):
result += ".comp-role" result += ".comp-role"
if self.role == "headword": if self.role == "headword":
result += ".comp-role-headword" result += ".comp-role-headword"
return result return result

Loading…
Cancel
Save