fixed id=null and moving collocations between senses
This commit is contained in:
parent
920ce87cfc
commit
596a0a372a
|
@ -48,13 +48,15 @@ def export_entry(entry):
|
||||||
# if({}) works uncorrectly in transcrypt
|
# if({}) works uncorrectly in transcrypt
|
||||||
if len(entry.lexical_unit) > 0 and len(entry.lexical_unit['lexemes']) > 0:
|
if len(entry.lexical_unit) > 0 and len(entry.lexical_unit['lexemes']) > 0:
|
||||||
lexunit = doc.createElement("lexicalUnit")
|
lexunit = doc.createElement("lexicalUnit")
|
||||||
|
if(entry.lexical_unit["id"]):
|
||||||
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"]:
|
||||||
lexeme_xml = doc.createElement("lexeme")
|
lexeme_xml = doc.createElement("lexeme")
|
||||||
|
if(lexeme["id"]):
|
||||||
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"]
|
||||||
if len(entry.lexical_unit["lexemes"] > 1):
|
if len(entry.lexical_unit["lexemes"]) > 1:
|
||||||
component = doc.createElement('component')
|
component = doc.createElement('component')
|
||||||
component.appendChild(lexeme_xml)
|
component.appendChild(lexeme_xml)
|
||||||
lexunit.appendChild(component)
|
lexunit.appendChild(component)
|
||||||
|
@ -231,7 +233,6 @@ def export_example_to_entry_xml(example, other_examples = None):
|
||||||
lexical_unit = doc.createElement("lexicalUnit")
|
lexical_unit = doc.createElement("lexicalUnit")
|
||||||
lexical_unit.setAttribute("type", "MWE")
|
lexical_unit.setAttribute("type", "MWE")
|
||||||
head.appendChild(lexical_unit)
|
head.appendChild(lexical_unit)
|
||||||
|
|
||||||
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:
|
||||||
|
@ -241,7 +242,6 @@ def export_example_to_entry_xml(example, other_examples = None):
|
||||||
lexical_unit.appendChild(comp_xml)
|
lexical_unit.appendChild(comp_xml)
|
||||||
comp_xml.appendChild(lexeme)
|
comp_xml.appendChild(lexeme)
|
||||||
|
|
||||||
|
|
||||||
grammar = doc.createElement("grammar")
|
grammar = doc.createElement("grammar")
|
||||||
category = doc.createElement("category")
|
category = doc.createElement("category")
|
||||||
grammar.appendChild(category)
|
grammar.appendChild(category)
|
||||||
|
|
|
@ -45,12 +45,13 @@ class Entry(Data):
|
||||||
lex_units = entry_xml.querySelectorAll("lexical_unit lexeme,lexicalUnit lexeme")
|
lex_units = entry_xml.querySelectorAll("lexical_unit lexeme,lexicalUnit lexeme")
|
||||||
lex_unit_parent = entry_xml.querySelector("lexicalUnit")
|
lex_unit_parent = entry_xml.querySelector("lexicalUnit")
|
||||||
self.lexical_unit['lexemes'] = []
|
self.lexical_unit['lexemes'] = []
|
||||||
self.lexical_unit['id'] = lex_unit_parent.getAttribute('id') if lex_unit_parent and lex_unit_parent.hasAttribute(
|
if lex_unit_parent and lex_unit_parent.hasAttribute("id"):
|
||||||
"id") else None
|
self.lexical_unit['id'] = lex_unit_parent.getAttribute('id')
|
||||||
self.lexical_unit['type'] = lex_unit_parent.getAttribute("type") if lex_unit_parent and lex_unit_parent.hasAttribute(
|
self.lexical_unit['type'] = lex_unit_parent.getAttribute("type") if lex_unit_parent and lex_unit_parent.hasAttribute(
|
||||||
"type") else "single"
|
"type") else "single"
|
||||||
for unit in lex_units:
|
for unit in lex_units:
|
||||||
lexical_unit = {}
|
lexical_unit = {}
|
||||||
|
if unit.hasAttribute("lexical_unit_lexeme_id"):
|
||||||
lexical_unit['id'] = unit.getAttribute("lexical_unit_lexeme_id")
|
lexical_unit['id'] = unit.getAttribute("lexical_unit_lexeme_id")
|
||||||
lexical_unit['text'] = unit.textContent
|
lexical_unit['text'] = unit.textContent
|
||||||
self.lexical_unit['lexemes'].append(lexical_unit)
|
self.lexical_unit['lexemes'].append(lexical_unit)
|
||||||
|
|
|
@ -185,12 +185,14 @@ def move_examples_to_sense(example_list, entry):
|
||||||
sense_of_first_example = example_senses[0]
|
sense_of_first_example = example_senses[0]
|
||||||
|
|
||||||
options = [h("p", {}, "Choose sense for examples")]
|
options = [h("p", {}, "Choose sense for examples")]
|
||||||
definition = ""
|
|
||||||
|
for idx, sense in enumerate(entry.senses):
|
||||||
|
definition = sense.definitions[0].value
|
||||||
for x in sense.definitions:
|
for x in sense.definitions:
|
||||||
if x["type"] == "indicator":
|
if x["type"] == "indicator":
|
||||||
definition = x.value
|
definition = x.value
|
||||||
break
|
break
|
||||||
for idx, sense in enumerate(entry.senses):
|
|
||||||
text = "{}: {}".format(idx + 1, definition)
|
text = "{}: {}".format(idx + 1, definition)
|
||||||
id_ = "choose-example-{}".format(idx)
|
id_ = "choose-example-{}".format(idx)
|
||||||
|
|
||||||
|
@ -201,7 +203,6 @@ def move_examples_to_sense(example_list, entry):
|
||||||
options.append(h("input#{}.checkable-input".format(id_), {"props": props}, []))
|
options.append(h("input#{}.checkable-input".format(id_), {"props": props}, []))
|
||||||
options.append(h("label.checkable", {"attrs": {"for": id_}}, text))
|
options.append(h("label.checkable", {"attrs": {"for": id_}}, text))
|
||||||
options.append(h("br", {}, []))
|
options.append(h("br", {}, []))
|
||||||
|
|
||||||
return modal_template(options, "Examples picker", (message.MoveExamplesToSense, example_list))
|
return modal_template(options, "Examples picker", (message.MoveExamplesToSense, example_list))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user