lexicalUnit from single lexeme to multiple lexeme support
This commit is contained in:
parent
eea25b9968
commit
bd4e64f818
|
@ -46,15 +46,17 @@ def export_entry(entry):
|
||||||
|
|
||||||
|
|
||||||
# if({}) works uncorrectly in transcrypt
|
# if({}) works uncorrectly in transcrypt
|
||||||
if len(entry.lexical_unit) > 0:
|
if len(entry.lexical_unit) > 0 and len(entry.lexical_unit['lexemes']) > 0:
|
||||||
lexunit = doc.createElement("lexicalUnit")
|
lexunit = doc.createElement("lexicalUnit")
|
||||||
lexunit.setAttribute("id", entry.lexical_unit["id"])
|
lexunit.setAttribute("id", entry.lexical_unit["id"])
|
||||||
lexunit.setAttribute("type", "single")
|
lexunit.setAttribute("type", entry.lexical_unit['type'])
|
||||||
lexeme = doc.createElement("lexeme")
|
for lexeme in entry.lexical_unit["lexemes"]:
|
||||||
lexeme.setAttribute("lexical_unit_lexeme_id", entry.lexical_unit["id"])
|
component = doc.createElement('component')
|
||||||
lexeme.textContent = entry.lexical_unit["text"]
|
lexeme_xml = doc.createElement("lexeme")
|
||||||
|
component.appendChild(lexeme_xml)
|
||||||
lexunit.appendChild(lexeme)
|
lexeme_xml.setAttribute("lexical_unit_lexeme_id", lexeme["id"])
|
||||||
|
lexeme_xml.textContent = lexeme["text"]
|
||||||
|
lexunit.appendChild(component)
|
||||||
head.appendChild(lexunit)
|
head.appendChild(lexunit)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,11 +42,18 @@ class Entry(Data):
|
||||||
self.variants = [v.textContent for v in entry_xml.querySelectorAll("head variantList variant")]
|
self.variants = [v.textContent for v in entry_xml.querySelectorAll("head variantList variant")]
|
||||||
self.homonymy = [{"value": v.textContent, "name": v.getAttribute("name")} for v in entry_xml.querySelectorAll("head headword homonymy homonymyFeature ")]
|
self.homonymy = [{"value": v.textContent, "name": v.getAttribute("name")} for v in entry_xml.querySelectorAll("head headword homonymy homonymyFeature ")]
|
||||||
self.related_entries = [re.textContent for re in entry_xml.querySelectorAll("head relatedEntryList relatedEntry")]
|
self.related_entries = [re.textContent for re in entry_xml.querySelectorAll("head relatedEntryList relatedEntry")]
|
||||||
|
lex_units = entry_xml.querySelectorAll("lexical_unit lexeme,lexicalUnit lexeme")
|
||||||
lex_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
|
lex_unit_parent = entry_xml.querySelector("lexicalUnit")
|
||||||
if lex_unit:
|
self.lexical_unit['lexemes'] = []
|
||||||
self.lexical_unit['id'] = lex_unit.getAttribute("lexical_unit_lexeme_id")
|
self.lexical_unit['id'] = lex_unit_parent.getAttribute('id') if lex_unit_parent and lex_unit_parent.hasAttribute(
|
||||||
self.lexical_unit['text'] = lex_unit.textContent
|
"id") else None
|
||||||
|
self.lexical_unit['type'] = lex_unit_parent.getAttribute("type") if lex_unit_parent and lex_unit_parent.hasAttribute(
|
||||||
|
"type") else "single"
|
||||||
|
for unit in lex_units:
|
||||||
|
lexical_unit = {}
|
||||||
|
lexical_unit['id'] = unit.getAttribute("lexical_unit_lexeme_id")
|
||||||
|
lexical_unit['text'] = unit.textContent
|
||||||
|
self.lexical_unit['lexemes'].append(lexical_unit)
|
||||||
|
|
||||||
measure = entry_xml.querySelector("measureList measure")
|
measure = entry_xml.querySelector("measureList measure")
|
||||||
if measure:
|
if measure:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user