Should be finished v4

This commit is contained in:
matic_t 2020-10-07 04:40:46 -07:00
parent fe3b3dfb0c
commit bc897dbe06

View File

@ -51,12 +51,15 @@ def export_entry(entry):
lexunit.setAttribute("id", entry.lexical_unit["id"]) lexunit.setAttribute("id", entry.lexical_unit["id"])
lexunit.setAttribute("type", entry.lexical_unit['type']) lexunit.setAttribute("type", entry.lexical_unit['type'])
for lexeme in entry.lexical_unit["lexemes"]: for lexeme in entry.lexical_unit["lexemes"]:
component = doc.createElement('component')
lexeme_xml = doc.createElement("lexeme") lexeme_xml = doc.createElement("lexeme")
component.appendChild(lexeme_xml)
lexeme_xml.setAttribute("lexical_unit_lexeme_id", lexeme["id"]) lexeme_xml.setAttribute("lexical_unit_lexeme_id", lexeme["id"])
lexeme_xml.textContent = lexeme["text"] lexeme_xml.textContent = lexeme["text"]
lexunit.appendChild(component) if len(entry.lexical_unit["lexemes"] > 1):
component = doc.createElement('component')
component.appendChild(lexeme_xml)
lexunit.appendChild(component)
else:
lexunit.appendChild(lexeme_xml)
head.appendChild(lexunit) head.appendChild(lexunit)
@ -218,6 +221,8 @@ def export_example_to_entry_xml(example, other_examples = None):
lemma = doc.createElement("lemma") lemma = doc.createElement("lemma")
lemma.textContent = " ".join(comp.text for comp in example.components) lemma.textContent = " ".join(comp.text for comp in example.components)
lemma.setAttribute("type", "compound") lemma.setAttribute("type", "compound")
if example.inner.other_attributes['audio'] is not None:
lemma.setAttribute('audio', example.inner.other_attributes['audio'])
headword.appendChild(lemma) headword.appendChild(lemma)
homonymy = doc.createElement("homonymy") homonymy = doc.createElement("homonymy")
@ -229,13 +234,13 @@ def export_example_to_entry_xml(example, other_examples = None):
if example.inner.other_attributes['structure_id'] != None and len(example.components) <= 3: if example.inner.other_attributes['structure_id'] != None and len(example.components) <= 3:
lexical_unit.setAttribute("id", example.inner.other_attributes['structure_id']) lexical_unit.setAttribute("id", example.inner.other_attributes['structure_id'])
for comp in example.components: for comp in example.components:
comp_xml = doc.createElement("component")
lexeme = doc.createElement("lexeme") lexeme = doc.createElement("lexeme")
lexeme.textContent = comp.text lexeme.textContent = comp.text
comp_xml.appendChild(lexeme) comp_xml = doc.createElement("component")
lexical_unit.appendChild(comp_xml) lexical_unit.appendChild(comp_xml)
comp_xml.appendChild(lexeme)
grammar = doc.createElement("grammar") grammar = doc.createElement("grammar")
category = doc.createElement("category") category = doc.createElement("category")