|
|
|
@ -91,25 +91,30 @@ def export_entry(entry):
|
|
|
|
|
|
|
|
|
|
# Same problem as homonymy
|
|
|
|
|
variants = _original_xml_query_selector("head variantList", entry, doc)
|
|
|
|
|
original_variants = entry.original_xml.querySelectorAll("head variantList variant")
|
|
|
|
|
og_variants = entry.original_xml.querySelectorAll("head variantList variant")
|
|
|
|
|
for v in entry.variants:
|
|
|
|
|
variant = doc.createElement("variant")
|
|
|
|
|
if v.id >= 0:
|
|
|
|
|
variant = original_variants[v.id]
|
|
|
|
|
variant = og_variants[v.id]
|
|
|
|
|
else:
|
|
|
|
|
variants.appendChild(variant)
|
|
|
|
|
|
|
|
|
|
variant.textContent = v.value
|
|
|
|
|
variants.appendChild(variant)
|
|
|
|
|
|
|
|
|
|
# relist = _original_xml_query_selector("head relatedEntryList", entry, doc)
|
|
|
|
|
relist = doc.createElement("relatedEntryList")
|
|
|
|
|
head.appendChild(relist.cloneNode(True))
|
|
|
|
|
|
|
|
|
|
# relist = doc.createElement("relatedEntryList")
|
|
|
|
|
relist = _original_xml_query_selector("head relatedEntryList", entry, doc)
|
|
|
|
|
og_relist = entry.original_xml.querySelectorAll("head relatedEntryList relatedEntry")
|
|
|
|
|
# head.appendChild(relist.cloneNode(True))
|
|
|
|
|
for re in entry.related_entries:
|
|
|
|
|
relateEntry = doc.createElement("relatedEntry")
|
|
|
|
|
relateEntry.textContent = re
|
|
|
|
|
relist.appendChild(relateEntry)
|
|
|
|
|
|
|
|
|
|
if re.id >= 0:
|
|
|
|
|
relateEntry = og_relist[re.id]
|
|
|
|
|
else:
|
|
|
|
|
relist.appendChild(relateEntry)
|
|
|
|
|
|
|
|
|
|
relateEntry.textContent = re.value
|
|
|
|
|
|
|
|
|
|
head.appendChild(_export_label_list(doc, entry.labels))
|
|
|
|
|
|
|
|
|
@ -129,12 +134,12 @@ def export_entry(entry):
|
|
|
|
|
sense_list = doc.createElement("senseList")
|
|
|
|
|
|
|
|
|
|
for sense in entry.senses:
|
|
|
|
|
sense_list.appendChild(export_sense(doc, sense))
|
|
|
|
|
sense_list.appendChild(export_sense(doc, sense, entry))
|
|
|
|
|
|
|
|
|
|
return entry.original_xml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def export_sense(doc, sense):
|
|
|
|
|
def export_sense(doc, sense, entry):
|
|
|
|
|
sense_xml = doc.createElement("sense")
|
|
|
|
|
sense_xml.appendChild(_export_label_list(doc, sense.labels))
|
|
|
|
|
|
|
|
|
@ -148,7 +153,7 @@ def export_sense(doc, sense):
|
|
|
|
|
definition_list.appendChild(definition)
|
|
|
|
|
|
|
|
|
|
translation_container_list = doc.createElement("translationContainerList")
|
|
|
|
|
export_translation_list(doc, sense, translation_container_list)
|
|
|
|
|
export_translation_list(doc, sense, translation_container_list, entry)
|
|
|
|
|
sense_xml.appendChild(translation_container_list)
|
|
|
|
|
|
|
|
|
|
example_container_list = doc.createElement("exampleContainerList")
|
|
|
|
@ -157,21 +162,21 @@ def export_sense(doc, sense):
|
|
|
|
|
for example in sense.examples:
|
|
|
|
|
example_container = example.export(doc)
|
|
|
|
|
translation_container_list = doc.createElement("translationContainerList")
|
|
|
|
|
export_translation_list(doc, example, translation_container_list)
|
|
|
|
|
export_translation_list(doc, example, translation_container_list, entry)
|
|
|
|
|
example_container.appendChild(translation_container_list)
|
|
|
|
|
example_container_list.appendChild(example_container)
|
|
|
|
|
|
|
|
|
|
return sense_xml
|
|
|
|
|
|
|
|
|
|
def export_translation_list(doc, py_parent, xml_parent):
|
|
|
|
|
def export_translation_list(doc, py_parent, xml_parent, entry):
|
|
|
|
|
for cidx, cluster in enumerate(py_parent.translations):
|
|
|
|
|
for translation in cluster:
|
|
|
|
|
translation_container = export_translation(doc, translation)
|
|
|
|
|
translation_container = export_translation(doc, translation, entry)
|
|
|
|
|
translation_container.setAttribute("cluster", str(cidx + 1))
|
|
|
|
|
xml_parent.appendChild(translation_container)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def export_translation(doc, translation):
|
|
|
|
|
def export_translation(doc, translation, entry):
|
|
|
|
|
translation_xml = doc.createElement("translationContainer")
|
|
|
|
|
translation_xml.appendChild(_export_label_list(doc, translation.tags))
|
|
|
|
|
|
|
|
|
@ -187,15 +192,19 @@ def export_translation(doc, translation):
|
|
|
|
|
translation_xml.appendChild(actual_t)
|
|
|
|
|
|
|
|
|
|
if len(translation.explanationList) > 0 :
|
|
|
|
|
explanationList = _export_explanation_list(doc, translation.explanationList)
|
|
|
|
|
explanationList = _export_explanation_list(doc, translation.explanationList, entry)
|
|
|
|
|
translation_xml.appendChild(explanationList)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return translation_xml
|
|
|
|
|
|
|
|
|
|
def _export_explanation_list(doc, lst):
|
|
|
|
|
def _export_explanation_list(doc, lst, entry):
|
|
|
|
|
debugger
|
|
|
|
|
# relist = _original_xml_query_selector("head relatedEntryList", entry, doc)
|
|
|
|
|
# og_relist = entry.original_xml.querySelectorAll("head relatedEntryList relatedEntry")
|
|
|
|
|
result = doc.createElement('explanationList')
|
|
|
|
|
|
|
|
|
|
for explanation in lst:
|
|
|
|
|
result.appendChild(explanation.export(doc))
|
|
|
|
|
|
|
|
|
|