mt-export-example-as-entry - v4.1 #9

Merged
matic_t merged 6 commits from mt-export-example-as-entry into master 2020-10-12 08:35:03 +00:00
Showing only changes of commit bc897dbe06 - Show all commits

View File

@ -51,12 +51,15 @@ def export_entry(entry):
lexunit.setAttribute("id", entry.lexical_unit["id"])
lexunit.setAttribute("type", entry.lexical_unit['type'])
for lexeme in entry.lexical_unit["lexemes"]:
component = doc.createElement('component')
lexeme_xml = doc.createElement("lexeme")
component.appendChild(lexeme_xml)
lexeme_xml.setAttribute("lexical_unit_lexeme_id", lexeme["id"])
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)
@ -218,6 +221,8 @@ def export_example_to_entry_xml(example, other_examples = None):
lemma = doc.createElement("lemma")
lemma.textContent = " ".join(comp.text for comp in example.components)
lemma.setAttribute("type", "compound")
if example.inner.other_attributes['audio'] is not None:
lemma.setAttribute('audio', example.inner.other_attributes['audio'])
headword.appendChild(lemma)
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:
lexical_unit.setAttribute("id", example.inner.other_attributes['structure_id'])
for comp in example.components:
comp_xml = doc.createElement("component")
lexeme = doc.createElement("lexeme")
lexeme.textContent = comp.text
comp_xml.appendChild(lexeme)
comp_xml = doc.createElement("component")
lexical_unit.appendChild(comp_xml)
comp_xml.appendChild(lexeme)
grammar = doc.createElement("grammar")
category = doc.createElement("category")