Compare commits
6 Commits
master
...
mt-dont-de
Author | SHA1 | Date | |
---|---|---|---|
|
45733b5cf7 | ||
|
f8bd865316 | ||
|
a26cbcf4d3 | ||
|
48a91ed67a | ||
|
e1ce093ff6 | ||
|
36cce3a86e |
220
src/export.py
220
src/export.py
|
@ -7,156 +7,197 @@ def export_to_xml(model):
|
|||
serializer = __new__(XMLSerializer())
|
||||
return serializer.serializeToString(xml_document)
|
||||
|
||||
|
||||
def export_entry(entry):
|
||||
parser = __new__(DOMParser())
|
||||
doc = parser.parseFromString("<entry />", "text/xml")
|
||||
entry_xml = doc.firstChild
|
||||
|
||||
# create head
|
||||
head = entry.original_xml.querySelector("head")
|
||||
if head is None:
|
||||
head = doc.createElement("head")
|
||||
entry_xml.appendChild(head)
|
||||
entry.original_xml.appendChild(head)
|
||||
# entry_xml.appendChild(head.cloneNode(True))
|
||||
|
||||
status = doc.createElement("status")
|
||||
status = _original_xml_query_selector("head status", entry, doc)
|
||||
status.textContent = entry.status
|
||||
head.appendChild(status)
|
||||
# head.appendChild(status.cloneNode(True))
|
||||
|
||||
headword = doc.createElement("headword")
|
||||
headword_lemma = doc.createElement("lemma")
|
||||
|
||||
# headword_lemma = entry.original_xml.querySelector("head headword lemma")
|
||||
|
||||
# headword = doc.createElement("headword")
|
||||
# headword_lemma = doc.createElement("lemma")
|
||||
|
||||
headword = _original_xml_query_selector("head headword", entry, doc)
|
||||
headword_lemma = _original_xml_query_selector("head headword lemma", entry, doc)
|
||||
|
||||
headword_lemma.textContent = entry.headword
|
||||
if entry.headword_type is not None:
|
||||
headword_lemma.setAttribute("type", entry.headword_type)
|
||||
if entry.headword_audio is not None:
|
||||
headword_lemma.setAttribute("audio", entry.headword_audio)
|
||||
headword.appendChild(headword_lemma)
|
||||
head.appendChild(headword)
|
||||
|
||||
homonymy = doc.createElement("homonymy")
|
||||
headword.appendChild(homonymy)
|
||||
# headword.appendChild(headword_lemma.cloneNode(True))
|
||||
# head.appendChild(headword.cloneNode(True))
|
||||
homonymy = _original_xml_query_selector("head headword homonymy", entry, doc)
|
||||
original_homonymy = entry.original_xml.querySelectorAll("head headword homonymy homonymyFeature")
|
||||
|
||||
for hFeature in entry.homonymy:
|
||||
feature = doc.createElement("homonymyFeature")
|
||||
feature.textContent = hFeature.value
|
||||
# Can't use hFeature.name, because Python has name reserver and so it becomes py_name in JS
|
||||
feature.setAttribute("name", hFeature["name"])
|
||||
if hFeature.id >= 0:
|
||||
feature = original_homonymy[hFeature.id]
|
||||
else:
|
||||
homonymy.appendChild(feature)
|
||||
|
||||
feature.textContent = hFeature.value
|
||||
# Can't use hFeature.name, because Python has name reserved and so it becomes py_name in JS
|
||||
feature.setAttribute("name", hFeature["name"])
|
||||
|
||||
|
||||
|
||||
# if({}) works uncorrectly in transcrypt
|
||||
if len(entry.lexical_unit) > 0:
|
||||
lexunit = doc.createElement("lexicalUnit")
|
||||
lexunit = _original_xml_query_selector("head lexicalUnit", entry, doc)
|
||||
# lexunit = doc.createElement("lexicalUnit")
|
||||
lexunit.setAttribute("id", entry.lexical_unit["id"])
|
||||
lexunit.setAttribute("type", "single")
|
||||
lexeme = doc.createElement("lexeme")
|
||||
lexeme = _original_xml_query_selector("head lexicalUnit lexeme", entry, doc)
|
||||
# lexeme = doc.createElement("lexeme")
|
||||
lexeme.setAttribute("lexical_unit_lexeme_id", entry.lexical_unit["id"])
|
||||
lexeme.textContent = entry.lexical_unit["text"]
|
||||
|
||||
lexunit.appendChild(lexeme)
|
||||
head.appendChild(lexunit)
|
||||
# lexunit.appendChild(lexeme.cloneNode(True))
|
||||
# head.appendChild(lexunit.cloneNode(True))
|
||||
|
||||
# Example of keeping original xml and adding changes to it only
|
||||
grammar_category = entry.original_xml.querySelector("head grammar category")
|
||||
if grammar_category is None:
|
||||
grammar = doc.createElement("grammar")
|
||||
grammar_category = doc.createElement("category")
|
||||
grammar.appendChild(grammar_category)
|
||||
entry.original_xml.querySelector("head").appendChild(grammar_category)
|
||||
|
||||
grammar = _original_xml_query_selector("head grammar", entry, doc)
|
||||
grammar_category = _original_xml_query_selector("head grammar category", entry, doc)
|
||||
grammar_category.textContent = entry.grammar
|
||||
|
||||
head.appendChild(entry.original_xml.querySelector("head grammar"))
|
||||
|
||||
# head.appendChild(grammar.cloneNode(True))
|
||||
console.log(entry.original_xml)
|
||||
|
||||
if len(entry.measure) > 0:
|
||||
measure_list = doc.createElement("measureList")
|
||||
measure = doc.createElement("measure")
|
||||
measure_list = _original_xml_query_selector("head measureList", entry, doc)
|
||||
measure = _original_xml_query_selector("head measureList measure", entry, doc)
|
||||
|
||||
# measure_list = doc.createElement("measureList")
|
||||
# measure = doc.createElement("measure")
|
||||
measure.setAttribute("source", entry.measure["source"])
|
||||
measure.setAttribute("type", entry.measure["type"])
|
||||
measure.textContent = entry.measure["text"]
|
||||
|
||||
measure_list.appendChild(measure)
|
||||
head.appendChild(measure_list)
|
||||
|
||||
variants = doc.createElement("variantList")
|
||||
head.appendChild(variants)
|
||||
# head.appendChild(measure_list)
|
||||
|
||||
# Same problem as homonymy
|
||||
variants = _original_xml_query_selector("head variantList", entry, doc)
|
||||
og_variants = entry.original_xml.querySelectorAll("head variantList variant")
|
||||
for v in entry.variants:
|
||||
variant = doc.createElement("variant")
|
||||
variant.textContent = v
|
||||
if v.id >= 0:
|
||||
variant = og_variants[v.id]
|
||||
else:
|
||||
variants.appendChild(variant)
|
||||
|
||||
relist = doc.createElement("relatedEntryList")
|
||||
head.appendChild(relist)
|
||||
variant.textContent = v.value
|
||||
|
||||
# relist = _original_xml_query_selector("head relatedEntryList", entry, doc)
|
||||
# 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
|
||||
|
||||
if re.id >= 0:
|
||||
relateEntry = og_relist[re.id]
|
||||
else:
|
||||
relist.appendChild(relateEntry)
|
||||
|
||||
head.appendChild(_export_label_list(doc, entry.labels))
|
||||
relateEntry.textContent = re.value
|
||||
_export_label_list(doc, entry.labels, head)
|
||||
|
||||
comment = doc.createElement("comment")
|
||||
# comment = doc.createElement("comment")
|
||||
comment = _original_xml_query_selector("head comment", entry, doc)
|
||||
comment.textContent = entry.comment
|
||||
head.appendChild(comment)
|
||||
# head.appendChild(comment.cloneNode(True))
|
||||
|
||||
# now lets do body
|
||||
|
||||
body = entry.original_xml.querySelector("body")
|
||||
if body is None:
|
||||
body = doc.createElement("body")
|
||||
entry_xml.appendChild(body)
|
||||
|
||||
sense_list = doc.createElement("senseList")
|
||||
body.appendChild(sense_list)
|
||||
entry.original_xml.appendChild(body)
|
||||
# entry_xml.appendChild(body)
|
||||
|
||||
# sense_list = doc.createElement("senseList")
|
||||
sense_list = _original_xml_query_selector("body senseList", entry, doc)
|
||||
for sense in entry.senses:
|
||||
sense_list.appendChild(export_sense(doc, sense))
|
||||
|
||||
return doc
|
||||
|
||||
|
||||
def export_sense(doc, sense):
|
||||
sense_xml = doc.createElement("sense")
|
||||
sense_xml.appendChild(_export_label_list(doc, sense.labels))
|
||||
|
||||
if sense.original_xml is not None:
|
||||
sense_xml = sense.original_xml
|
||||
|
||||
sense_list.appendChild(sense_xml)
|
||||
export_sense(doc, sense, sense_xml)
|
||||
|
||||
return entry.original_xml
|
||||
|
||||
|
||||
def export_sense(doc, sense, sense_xml):
|
||||
_export_label_list(doc, sense.labels, sense_xml)
|
||||
|
||||
definition_list = sense_xml.querySelector("definitionList")
|
||||
if definition_list is None:
|
||||
definition_list = doc.createElement("definitionList")
|
||||
sense_xml.appendChild(definition_list)
|
||||
|
||||
for typ, text in sense.definition.items():
|
||||
definition = doc.createElement("definition")
|
||||
definition.textContent = text
|
||||
definition.setAttribute("type", typ)
|
||||
definition_list.appendChild(definition)
|
||||
for definition in sense.definitions:
|
||||
definition_xml = definition.original_xml if definition.original_xml != None else doc.createElement("definition")
|
||||
definition_list.appendChild(definition_xml)
|
||||
definition_xml.textContent = definition.value
|
||||
definition_xml.setAttribute("type", definition.type)
|
||||
|
||||
translation_container_list = sense_xml.querySelector("sense > translationContainerList")
|
||||
if translation_container_list is None:
|
||||
translation_container_list = doc.createElement("translationContainerList")
|
||||
export_translation_list(doc, sense, translation_container_list)
|
||||
sense_xml.appendChild(translation_container_list)
|
||||
export_translation_list(doc, sense, translation_container_list)
|
||||
|
||||
example_container_list = sense_xml.querySelector("sense > exampleContainerList")
|
||||
if example_container_list is None:
|
||||
example_container_list = doc.createElement("exampleContainerList")
|
||||
sense_xml.appendChild(example_container_list)
|
||||
|
||||
for example in sense.examples:
|
||||
example_container = example.export(doc)
|
||||
translation_container_list = doc.createElement("translationContainerList")
|
||||
export_translation_list(doc, example, translation_container_list)
|
||||
example_container.appendChild(translation_container_list)
|
||||
example_container_list.appendChild(example_container)
|
||||
example_container = example.export(doc, example_container_list)
|
||||
|
||||
translation_container_list = example_container.querySelector("exampleContainer > translationContainerList")
|
||||
if translation_container_list is None:
|
||||
translation_container_list = doc.createElement("translationContainerList")
|
||||
example_container.appendChild(translation_container_list)
|
||||
|
||||
export_translation_list(doc, example, translation_container_list)
|
||||
|
||||
return sense_xml
|
||||
|
||||
def export_translation_list(doc, py_parent, xml_parent):
|
||||
for cidx, cluster in enumerate(py_parent.translations):
|
||||
for translation in cluster:
|
||||
translation_container = export_translation(doc, translation)
|
||||
translation_container = export_translation(doc, translation, xml_parent)
|
||||
translation_container.setAttribute("cluster", str(cidx + 1))
|
||||
xml_parent.appendChild(translation_container)
|
||||
# xml_parent.appendChild(translation_container)
|
||||
|
||||
|
||||
def export_translation(doc, translation):
|
||||
translation_xml = doc.createElement("translationContainer")
|
||||
translation_xml.appendChild(_export_label_list(doc, translation.tags))
|
||||
def export_translation(doc, translation, xml_parent):
|
||||
translation_xml = translation.original_xml if translation.original_xml != None else doc.createElement("translationContainer")
|
||||
xml_parent.appendChild(translation_xml)
|
||||
_export_label_list(doc, translation.tags, translation_xml)
|
||||
|
||||
console.log(translation)
|
||||
actual_t = translation.original_xml.querySelector("translation") if translation.original_xml != None else doc.createElement("translation")
|
||||
if translation.original_xml is None:
|
||||
translation_xml.appendChild(actual_t)
|
||||
|
||||
actual_t = doc.createElement("translation")
|
||||
actual_t.textContent = translation.translation
|
||||
actual_t.setAttribute("targetLang", translation.targetLang)
|
||||
|
||||
|
@ -165,30 +206,43 @@ def export_translation(doc, translation):
|
|||
|
||||
if translation.source:
|
||||
actual_t.setAttribute("source", translation.source)
|
||||
translation_xml.appendChild(actual_t)
|
||||
|
||||
if len(translation.explanationList) > 0 :
|
||||
explanationList = _export_explanation_list(doc, translation.explanationList)
|
||||
translation_xml.appendChild(explanationList)
|
||||
|
||||
|
||||
_export_explanation_list(doc, translation.explanationList, translation_xml)
|
||||
|
||||
return translation_xml
|
||||
|
||||
def _export_explanation_list(doc, lst):
|
||||
result = doc.createElement('explanationList')
|
||||
def _export_explanation_list(doc, lst, xml_parent):
|
||||
result = xml_parent.querySelector("explanationList")
|
||||
if result is None:
|
||||
result = doc.createElement("explanationList")
|
||||
xml_parent.appendChild(result)
|
||||
|
||||
for explanation in lst:
|
||||
result.appendChild(explanation.export(doc))
|
||||
|
||||
return result
|
||||
|
||||
def _export_label_list(doc, lst):
|
||||
def _export_label_list(doc, lst, xml_parent):
|
||||
result = xml_parent.querySelector("labelList")
|
||||
if result is None:
|
||||
result = doc.createElement("labelList")
|
||||
for key, value in lst:
|
||||
key, value = export_tag(key, value)
|
||||
xml_parent.appendChild(result)
|
||||
|
||||
for key, value, idx in lst:
|
||||
|
||||
key, value = export_tag(key, value)
|
||||
label_el = doc.createElement("label")
|
||||
if idx >= 0:
|
||||
label_el = result.querySelectorAll("label")[idx]
|
||||
else:
|
||||
result.appendChild(label_el)
|
||||
|
||||
label_el.textContent = value
|
||||
label_el.setAttribute('type', key)
|
||||
result.appendChild(label_el)
|
||||
return result
|
||||
|
||||
def _original_xml_query_selector(selector, entry, doc, parent_selector = selector.rsplit(' ', 1)[0]):
|
||||
query = entry.original_xml.querySelector(selector)
|
||||
if query is None:
|
||||
query = doc.createElement(selector.rsplit(' ', 1)[1])
|
||||
entry.original_xml.querySelector(parent_selector).appendChild(query)
|
||||
return query
|
||||
|
|
|
@ -4,8 +4,10 @@ from browser import document
|
|||
def generic_list_getter():
|
||||
result = []
|
||||
for input_el in document.getElementsByClassName("list-adder-input"):
|
||||
result_candidate = input_el.value
|
||||
if result_candidate != "":
|
||||
result_candidate = {"value": input_el.value}
|
||||
if input_el.hasAttribute("data-id"):
|
||||
result_candidate.id = int(input_el.getAttribute("data-id"))
|
||||
if result_candidate.value != "":
|
||||
result.append(result_candidate)
|
||||
return result
|
||||
|
||||
|
@ -13,16 +15,19 @@ def generic_list_getter():
|
|||
def double_list_getter(firstParameter, secondParameter, allowEmptyField = False):
|
||||
result = []
|
||||
for row in document.getElementsByClassName("double-list-row"):
|
||||
firstValue = row.querySelector("." + firstParameter + "-input").value
|
||||
secondValue = row.querySelector("." + secondParameter + "-input").value
|
||||
output = {}
|
||||
output[firstParameter] = row.querySelector("." + firstParameter + "-input").value
|
||||
output[secondParameter] = row.querySelector("." + secondParameter + "-input").value
|
||||
if row.hasAttribute("data-id"):
|
||||
output.id = int(row.getAttribute("data-id"))
|
||||
|
||||
if (allowEmptyField is False and '' in [firstValue, secondValue]):
|
||||
if (allowEmptyField is False and '' in [output[firstParameter], output[secondParameter]]):
|
||||
continue
|
||||
|
||||
if (allowEmptyField is True and all('' == value or value.isspace() for value in [firstValue, secondValue])):
|
||||
if (allowEmptyField is True and all('' == value or value.isspace() for value in [output[firstParameter], output[secondParameter]])):
|
||||
continue
|
||||
|
||||
result.append({firstParameter: firstValue, secondParameter: secondValue})
|
||||
result.append(output)
|
||||
|
||||
return result
|
||||
|
||||
|
@ -33,6 +38,7 @@ def label_list_getter():
|
|||
ltype = row.querySelector(".label-type")
|
||||
lvalue = row.querySelector(".label-value")
|
||||
lother = row.querySelector(".label-value-other")
|
||||
idx = int(row.getAttribute("data-id")) if row.hasAttribute("data-id") else -1
|
||||
|
||||
if lother is None:
|
||||
continue
|
||||
|
@ -44,7 +50,7 @@ def label_list_getter():
|
|||
if not value:
|
||||
continue
|
||||
|
||||
result.append((ltype.textContent, value))
|
||||
result.append((ltype.textContent, value, idx))
|
||||
|
||||
kontrastivno = document.getElementById("kontrastivno-input").checked;
|
||||
if kontrastivno:
|
||||
|
|
|
@ -21,7 +21,9 @@ class DeleteRelatedEntries(DeleteVariants):
|
|||
|
||||
class DeleteHomonymy(NoReset):
|
||||
def update_model(self, model):
|
||||
for el in document.getElementsByClassName("list-adder-input"):
|
||||
for el in document.getElementsByClassName("name-input"):
|
||||
el.value = ""
|
||||
for el in document.getElementsByClassName("value-input"):
|
||||
el.value = ""
|
||||
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class EditExampleText(Message):
|
|||
if example.newly_created:
|
||||
example.newly_created = False
|
||||
sense.examples.append(example)
|
||||
|
||||
console.log(example)
|
||||
idx = 0
|
||||
for txt in document.getElementsByClassName("example-component-text"):
|
||||
example.components[idx].text = txt.value
|
||||
|
|
|
@ -18,10 +18,15 @@ class SenseMoveUp(DataChgClickMessage):
|
|||
assert(sidx >= 0)
|
||||
if sidx == 0:
|
||||
return
|
||||
# if sense.original_idx >= 0:
|
||||
# if model.entry.senses[sidx - 1].original_idx >= 0:
|
||||
# original_parent = model.entry.original_xml.querySelector("body senseList")
|
||||
# original_parent.insertBefore(original_parent.children[sidx], original_parent.children[sidx - 1])
|
||||
# model.entry.senses[sidx].original_idx, model.entry.senses[sidx - 1].original_idx = model.entry.senses[sidx - 1].original_idx, model.entry.senses[sidx].original_idx
|
||||
# else:
|
||||
|
||||
model.entry.senses[sidx], model.entry.senses[sidx - 1] = model.entry.senses[sidx - 1], model.entry.senses[sidx]
|
||||
|
||||
|
||||
class SenseMoveDown(DataChgClickMessage):
|
||||
def update_model(self, model):
|
||||
sense = self.get_arg(0, Sense)
|
||||
|
@ -30,7 +35,10 @@ class SenseMoveDown(DataChgClickMessage):
|
|||
assert(sidx >= 0)
|
||||
if sidx == len(model.senses) - 1:
|
||||
return
|
||||
|
||||
# if sense.original_idx >= 0 and model.entry.senses[sidx + 1].original_idx >= 0:
|
||||
# original_parent = model.entry.original_xml.querySelector("body senseList")
|
||||
# original_parent.insertBefore(original_parent.children[sidx + 1], original_parent.children[sidx])
|
||||
# model.entry.senses[sidx].original_idx, model.entry.senses[sidx + 1].original_idx = model.entry.senses[sidx + 1].original_idx, model.entry.senses[sidx].original_idx
|
||||
model.entry.senses[sidx], model.entry.senses[sidx + 1] = model.entry.senses[sidx + 1], model.entry.senses[sidx]
|
||||
|
||||
|
||||
|
@ -42,6 +50,12 @@ class SenseBin(DataChgClickMessage):
|
|||
assert(sidx >= 0)
|
||||
model.entry.senses.splice(sidx, 1)
|
||||
|
||||
# if sense.original_idx >= 0:
|
||||
# model.entry.original_xml.querySelectorAll("body senseList sense")[sense.original_idx].remove()
|
||||
# for index, sense in enumerate(model.entry.senses):
|
||||
# if (sense.original_idx >= 0):
|
||||
# sense.original_idx = index
|
||||
|
||||
|
||||
class AddMultiwordExample(DataChgClickMessage):
|
||||
def on_event(self, event):
|
||||
|
|
|
@ -17,6 +17,14 @@ class EditSenseLabel(Message):
|
|||
sense = self.get_arg(0, Sense)
|
||||
sense.labels = common_accessors.label_list_getter()
|
||||
|
||||
keptIds = [entry[2] for entry in sense.labels]
|
||||
for index, entry in enumerate(sense.original_xml.querySelectorAll("labelList label")):
|
||||
if (index not in keptIds):
|
||||
entry.remove()
|
||||
|
||||
for index, entry in enumerate(sense.labels):
|
||||
if (entry[2] >= 0):
|
||||
entry[2] = index
|
||||
|
||||
class AddToGenericList(NoReset):
|
||||
def update_model(self, model):
|
||||
|
@ -43,14 +51,14 @@ class AddToLabelList(NoReset):
|
|||
class AddSense(Message):
|
||||
def update_model(self, model):
|
||||
sense = Sense()
|
||||
sense.definition = {"indicator": "New Sense"}
|
||||
sense.definitions.append({"type": "indicator", "value": "New Sense"})
|
||||
model.entry.senses.append(sense)
|
||||
|
||||
|
||||
class EditSenseDefinition(QuestionMessage):
|
||||
def update_model(self, model):
|
||||
sense = self.get_arg(0, Sense)
|
||||
sense.definition["indicator"] = self.new_text
|
||||
sense.definitions[0].value = self.new_text
|
||||
|
||||
|
||||
class EditComment(QuestionMessage):
|
||||
|
@ -86,23 +94,36 @@ class DoChosenExamples(Message):
|
|||
class EditVariants(Message):
|
||||
def update_model(self, model):
|
||||
variants = common_accessors.generic_list_getter()
|
||||
update_entries(variants, "head variantList variant", model)
|
||||
model.entry.variants = variants
|
||||
|
||||
class EditHomonymy(Message):
|
||||
def update_model(self, model):
|
||||
homonymy = common_accessors.double_list_getter("value", "name")
|
||||
|
||||
update_entries(homonymy, "head headword homonymy homonymyFeature", model)
|
||||
|
||||
model.entry.homonymy = homonymy
|
||||
|
||||
|
||||
class EditRelatedEntries(Message):
|
||||
def update_model(self, model):
|
||||
related_entries = common_accessors.generic_list_getter()
|
||||
update_entries(related_entries, "head relatedEntryList relatedEntry", model)
|
||||
model.entry.related_entries = related_entries
|
||||
|
||||
|
||||
class EditEntryLabels(Message):
|
||||
def update_model(self, model):
|
||||
labels = common_accessors.label_list_getter()
|
||||
keptIds = [entry[2] for entry in labels]
|
||||
for index, entry in enumerate(model.entry.original_xml.querySelectorAll("labelList label")):
|
||||
if (index not in keptIds):
|
||||
entry.remove()
|
||||
|
||||
for index, entry in enumerate(labels):
|
||||
if (entry[2] >= 0):
|
||||
entry[2] = index
|
||||
model.entry.labels = labels
|
||||
|
||||
|
||||
|
@ -118,3 +139,13 @@ class ExampleClusterAdd(DataChgClickMessage):
|
|||
example = self.get_arg(0, Example)
|
||||
example.set_cluster(ExampleClusters.first_empty_cluster())
|
||||
|
||||
|
||||
def update_entries(updated_list, query, model):
|
||||
keptIds = [entry.id for entry in updated_list]
|
||||
for index, entry in enumerate(model.entry.original_xml.querySelectorAll(query)):
|
||||
if (index not in keptIds):
|
||||
entry.remove()
|
||||
|
||||
for index, entry in enumerate(updated_list):
|
||||
if (entry.id >= 0):
|
||||
entry.id = index
|
||||
|
|
|
@ -14,6 +14,7 @@ class EditTranslation(DataChgClickMessage):
|
|||
self.old_cluster_idx = self.get_arg(1, int)
|
||||
|
||||
self.translation.translation = document.getElementById("etv").value
|
||||
|
||||
# This could be dangerous if double_list_getter is getting data from any other list as well.
|
||||
explanations = common_accessors.double_list_getter('value', 'language', True)
|
||||
self.translation.explanationList = []
|
||||
|
@ -21,10 +22,19 @@ class EditTranslation(DataChgClickMessage):
|
|||
explanation = Explanation()
|
||||
explanation.value = entry.value
|
||||
explanation.language = entry.language
|
||||
explanation.original_xml = entry.original_xml if entry.original_xml != None else None
|
||||
self.translation.explanationList.append(explanation)
|
||||
|
||||
# common_accessors.label_list_getter()
|
||||
self.translation.tags = common_accessors.label_list_getter()
|
||||
keptIds = [entry[2] for entry in self.translation.tags]
|
||||
for index, entry in enumerate(self.translation.original_xml.querySelectorAll("labelList label")):
|
||||
if (index not in keptIds):
|
||||
entry.remove()
|
||||
|
||||
for index, entry in enumerate(self.translation.tags):
|
||||
if (entry[2] >= 0):
|
||||
entry[2] = index
|
||||
# check if empty, remove!
|
||||
if self.translation.is_empty():
|
||||
model.entry.remove_translation(self.translation)
|
||||
|
|
|
@ -63,7 +63,7 @@ class Data:
|
|||
return None
|
||||
|
||||
def overwrite_with_copy(self):
|
||||
for key, value in dict(self._copy).items():
|
||||
for key, value in dict(self).items():
|
||||
# skip functions and _copy
|
||||
if key == "_copy" or type(value) is None:
|
||||
continue
|
||||
|
|
|
@ -26,7 +26,8 @@ class Entry(Data):
|
|||
self.original_xml = None
|
||||
|
||||
def import_xml(self, entry_xml):
|
||||
self.original_xml = entry_xml.cloneNode(True)
|
||||
console.log(entry_xml)
|
||||
self.original_xml = entry_xml
|
||||
status = entry_xml.querySelector("head status")
|
||||
|
||||
headword = entry_xml.querySelector("head headword lemma")
|
||||
|
@ -39,9 +40,9 @@ class Entry(Data):
|
|||
self.headword_audio = headword.getAttribute("audio") if headword and headword.hasAttribute("audio") else None
|
||||
self.grammar = grammar.textContent if grammar else ""
|
||||
self.comment = comment.textContent if comment else ""
|
||||
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.related_entries = [re.textContent for re in entry_xml.querySelectorAll("head relatedEntryList relatedEntry")]
|
||||
self.variants = [{"value": v.textContent, "id": index} for index, v in enumerate(entry_xml.querySelectorAll("head variantList variant"))]
|
||||
self.homonymy = [{"value": v.textContent, "name": v.getAttribute("name"), "id": index} for index, v in enumerate(entry_xml.querySelectorAll("head headword homonymy homonymyFeature "))]
|
||||
self.related_entries = [{"value": re.textContent, "id": index} for index, re in enumerate(entry_xml.querySelectorAll("head relatedEntryList relatedEntry"))]
|
||||
|
||||
lex_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
|
||||
if lex_unit:
|
||||
|
@ -54,12 +55,13 @@ class Entry(Data):
|
|||
self.measure["type"] = measure.getAttribute("type")
|
||||
self.measure["text"] = measure.textContent
|
||||
|
||||
self.labels = import_label_list("head labelList label", entry_xml)
|
||||
self.labels = import_label_list("head labelList label", self.original_xml)
|
||||
|
||||
for i, sense_xml in enumerate(entry_xml.querySelectorAll("body senseList sense")):
|
||||
sense = Sense()
|
||||
sense.import_xml(sense_xml, i)
|
||||
self.senses.append(sense)
|
||||
sense_xml.remove()
|
||||
|
||||
|
||||
def view(self, model):
|
||||
|
@ -96,7 +98,7 @@ class Entry(Data):
|
|||
if len(self.variants) == 0:
|
||||
view_buttons.append(buttons[0])
|
||||
else:
|
||||
view_table.append((buttons[0], ", ".join(self.variants)))
|
||||
view_table.append((buttons[0], ", ".join(v.value for v in self.variants)))
|
||||
|
||||
if len(self.homonymy) == 0:
|
||||
view_buttons.append(buttons[4])
|
||||
|
@ -106,7 +108,7 @@ class Entry(Data):
|
|||
if len(self.related_entries) == 0:
|
||||
view_buttons.append(buttons[1])
|
||||
else:
|
||||
view_table.append((buttons[1], ", ".join(self.related_entries)))
|
||||
view_table.append((buttons[1], ", ".join(re.value for re in self.related_entries)))
|
||||
|
||||
if len(self.labels) == 0:
|
||||
view_buttons.append(buttons[2])
|
||||
|
@ -141,4 +143,3 @@ class Entry(Data):
|
|||
if translation in cluster:
|
||||
cluster.remove(translation)
|
||||
return
|
||||
|
||||
|
|
|
@ -11,8 +11,10 @@ class ComponentLexeme(Data):
|
|||
self.text = ""
|
||||
self.role = ""
|
||||
self.no_space = False
|
||||
self.original_xml = None
|
||||
|
||||
def import_xml(self, xml):
|
||||
self.original_xml = xml.cloneNode(True)
|
||||
if xml.nodeName == "#text":
|
||||
self.text = xml.data
|
||||
self.role = None
|
||||
|
@ -25,6 +27,7 @@ class ComponentLexeme(Data):
|
|||
for oth_attr in ["lexeme_id", "lexical_unit_lexeme_id", "slolex", "kol", "sloleks"]:
|
||||
if xml.hasAttribute(oth_attr):
|
||||
self.other_attributes[oth_attr] = xml.getAttribute(oth_attr)
|
||||
xml.remove()
|
||||
|
||||
def isValid(self):
|
||||
return len(self.text) > 0
|
||||
|
@ -32,7 +35,8 @@ class ComponentLexeme(Data):
|
|||
def export(self, doc):
|
||||
if self.role is None:
|
||||
return doc.createTextNode(self.text)
|
||||
result = doc.createElement("comp")
|
||||
result = self.original_xml if self.original_xml is not None else doc.createElement("comp")
|
||||
|
||||
result.setAttribute("role", self.role)
|
||||
result.textContent = self.text
|
||||
|
||||
|
|
|
@ -3,14 +3,17 @@ from lib.snabbdom import h
|
|||
class CorpusExample:
|
||||
def __init__(self):
|
||||
self.other_attributes = {}
|
||||
self.original_xml = None
|
||||
|
||||
def import_xml(self, example_xml):
|
||||
for oth_attr in ["example_id", "modified", "lexical_unit_id", "audio"]:
|
||||
if example_xml.hasAttribute(oth_attr):
|
||||
self.other_attributes[oth_attr] = example_xml.getAttribute(oth_attr)
|
||||
self.original_xml = example_xml
|
||||
example_xml.remove()
|
||||
|
||||
def export(self, doc, modified):
|
||||
result = doc.createElement("corpusExample")
|
||||
result = self.original_xml if self.original_xml is not None else doc.createElement("corpusExample")
|
||||
if modified:
|
||||
result.setAttribute("modified", "true")
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ from model.example_clusters import ExampleClusters
|
|||
|
||||
class Example(Data):
|
||||
def __init__(self):
|
||||
self.original_xml = None
|
||||
self.translations = []
|
||||
self.inner = None
|
||||
self.components = []
|
||||
|
@ -41,20 +42,20 @@ class Example(Data):
|
|||
|
||||
def import_xml(self, example_xml):
|
||||
self.translations = from_container_list(example_xml.querySelectorAll("translationContainerList translationContainer"))
|
||||
|
||||
self.original_xml = example_xml.cloneNode(True)
|
||||
if example_xml.hasAttribute("modified"):
|
||||
self.edited = example_xml.getAttribute("modified") == "true"
|
||||
|
||||
inner_xml = example_xml.querySelector("corpusExample")
|
||||
inner_xml = self.original_xml.querySelector("corpusExample")
|
||||
if inner_xml is not None:
|
||||
self.inner = CorpusExample()
|
||||
else:
|
||||
inner_xml = example_xml.querySelector("multiwordExample")
|
||||
inner_xml = self.original_xml.querySelector("multiwordExample")
|
||||
self.inner = MultiwordExample()
|
||||
|
||||
self.inner.import_xml(inner_xml)
|
||||
|
||||
for idx, comp_xml in enumerate(inner_xml.childNodes):
|
||||
for idx, comp_xml in enumerate(self.inner.original_xml.childNodes):
|
||||
comp = ComponentLexeme()
|
||||
comp.import_xml(comp_xml)
|
||||
if comp.isValid():
|
||||
|
@ -62,11 +63,10 @@ class Example(Data):
|
|||
|
||||
self.check_multiword_components()
|
||||
|
||||
def export(self, doc):
|
||||
def export(self, doc, xml_parent):
|
||||
self.check_multiword_components()
|
||||
|
||||
result = doc.createElement("exampleContainer")
|
||||
|
||||
result = self.original_xml if self.original_xml != None else doc.createElement("exampleContainer")
|
||||
xml_parent.appendChild(result)
|
||||
inner = self.inner.export(doc, self.edited)
|
||||
# TODO: bad quick fix
|
||||
for comp in self.components:
|
||||
|
|
|
@ -6,8 +6,10 @@ class MultiwordExample:
|
|||
self.other_attributes = {}
|
||||
self.cluster = -1
|
||||
self.type = None
|
||||
self.original_xml = None
|
||||
|
||||
def import_xml(self, example_xml):
|
||||
self.original_xml = example_xml.cloneNode(True)
|
||||
for oth_attr in ["lexical_unit_id", "structure_id", "structureName", "audio", "frequency", "logDice"]:
|
||||
if example_xml.hasAttribute(oth_attr):
|
||||
self.other_attributes[oth_attr] = example_xml.getAttribute(oth_attr)
|
||||
|
@ -17,6 +19,9 @@ class MultiwordExample:
|
|||
if example_xml.hasAttribute("type"):
|
||||
self.type = example_xml.getAttribute("type")
|
||||
|
||||
|
||||
example_xml.remove()
|
||||
|
||||
@staticmethod
|
||||
def _determine_cluster_number(example_xml):
|
||||
if not example_xml.hasAttribute("cluster"):
|
||||
|
@ -27,8 +32,8 @@ class MultiwordExample:
|
|||
return cluster
|
||||
|
||||
def export(self, doc, _modified):
|
||||
result = doc.createElement("multiwordExample")
|
||||
|
||||
result = self.original_xml if self.original_xml is not None else doc.createElement("multiwordExample")
|
||||
# result = doc.createElement("multiwordExample")
|
||||
for key, value in self.other_attributes.items():
|
||||
result.setAttribute(key, value)
|
||||
|
||||
|
|
|
@ -7,14 +7,15 @@ class Explanation(Data):
|
|||
def __init__(self):
|
||||
self.value = ""
|
||||
self.language = ""
|
||||
self.original_xml = None
|
||||
|
||||
def import_dom(self, explanation_dom):
|
||||
|
||||
self.value = explanation_dom.textContent if explanation_dom else ""
|
||||
self.language = explanation_dom.getAttribute("language") if explanation_dom.hasAttribute("language") else ""
|
||||
def import_dom(self, explanation_xml):
|
||||
self.original_xml = explanation_xml.cloneNode(True)
|
||||
self.value = explanation_xml.textContent if explanation_xml else ""
|
||||
self.language = explanation_xml.getAttribute("language") if explanation_xml.hasAttribute("language") else ""
|
||||
|
||||
def export(self, doc):
|
||||
result = doc.createElement("explanation")
|
||||
result = self.original_xml if self.original_xml != None else doc.createElement("explanation")
|
||||
result.textContent = self.value
|
||||
if self.language != "": result.setAttribute('language', self.language)
|
||||
|
||||
|
|
|
@ -11,25 +11,34 @@ from view.utils import clean_label
|
|||
class Sense(Data):
|
||||
def __init__(self):
|
||||
self.original_idx = -1
|
||||
self.definition = {}
|
||||
self.original_xml = None
|
||||
self.definitions = []
|
||||
self.labels = []
|
||||
self.translations = []
|
||||
self.examples = []
|
||||
|
||||
def import_xml(self, sense_xml, idx):
|
||||
self.original_idx = idx
|
||||
self.original_xml = sense_xml.cloneNode(True)
|
||||
|
||||
for definition in sense_xml.querySelectorAll("definitionList definition"):
|
||||
key = definition.getAttribute("type")
|
||||
self.definition[key] = definition.textContent
|
||||
for definition in self.original_xml.querySelectorAll("definitionList definition"):
|
||||
definition_object = {}
|
||||
definition_object.type = definition.getAttribute("type")
|
||||
definition_object.value = definition.textContent
|
||||
definition_object.original_xml = definition
|
||||
definition.remove()
|
||||
self.definitions.append(definition_object)
|
||||
|
||||
self.labels = import_label_list("sense > labelList label", sense_xml)
|
||||
self.labels = import_label_list("sense > labelList label", self.original_xml)
|
||||
self.translations = from_container_list(
|
||||
sense_xml.querySelectorAll('sense > translationContainerList translationContainer'))
|
||||
for example_xml in sense_xml.querySelectorAll("exampleContainerList exampleContainer"):
|
||||
self.original_xml.querySelectorAll('sense > translationContainerList translationContainer'))
|
||||
for example_xml in self.original_xml.querySelectorAll("exampleContainerList exampleContainer"):
|
||||
example = Example()
|
||||
example.import_xml(example_xml)
|
||||
self.examples.append(example)
|
||||
example_xml.remove()
|
||||
|
||||
console.log(self.original_xml)
|
||||
|
||||
|
||||
def merge_labels(self):
|
||||
|
@ -44,7 +53,7 @@ class Sense(Data):
|
|||
h("div.sense", {}, [
|
||||
h("span.sense-label-list", { "on": { "click": M.msg(M.ShowSenseLabelEdit, self) }}, [
|
||||
h("span.sense-label", {}, clean_label(slabel)) for _, slabel in self.labels ]),
|
||||
h("span.sense-definition", { "on": { "click": M.msg(M.ShowSenseDefinitionEdit, self) }}, self.definition["indicator"]),
|
||||
h("span.sense-definition", { "on": { "click": M.msg(M.ShowSenseDefinitionEdit, self) }}, ", ".join(d.value for d in self.definitions)),
|
||||
h("div", {}, View.view_translations(self.translations, self, model)),
|
||||
h("div", {}, examples)])])
|
||||
return result
|
||||
|
|
|
@ -35,12 +35,12 @@ STYLE_SECTIONS = [("registrske", "register"),
|
|||
|
||||
def import_label_list(selector, xml_element):
|
||||
result = []
|
||||
for tag_xml in xml_element.querySelectorAll(selector):
|
||||
for index, tag_xml in enumerate(xml_element.querySelectorAll(selector)):
|
||||
t_type = tag_xml.getAttribute("type")
|
||||
t_value = tag_xml.textContent
|
||||
|
||||
t_type, t_value = import_tag(t_type, t_value)
|
||||
result.append((t_type, t_value))
|
||||
result.append((t_type, t_value, index))
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ def from_container_list(translation_list_container_xml):
|
|||
t = Translation()
|
||||
t.import_xml(translation_xml)
|
||||
translations.append((num_cluster, t))
|
||||
translation_xml.remove()
|
||||
|
||||
|
||||
result = [[] for _ in range(max_num_cluster)]
|
||||
for clusterNum, translation in translations:
|
||||
|
@ -30,6 +32,7 @@ def from_container_list(translation_list_container_xml):
|
|||
|
||||
class Translation(Data):
|
||||
def __init__(self, translation_xml):
|
||||
self.original_xml = None
|
||||
self.translation = ""
|
||||
self.source = ""
|
||||
self.targetLang = ""
|
||||
|
@ -39,6 +42,7 @@ class Translation(Data):
|
|||
|
||||
def import_xml(self, translation_xml):
|
||||
translation = translation_xml.querySelector("translation")
|
||||
self.original_xml = translation_xml.cloneNode(True)
|
||||
|
||||
if translation:
|
||||
self.translation = translation.textContent
|
||||
|
@ -46,13 +50,13 @@ class Translation(Data):
|
|||
self.targetLang = translation.getAttribute("targetLang") if translation.hasAttribute("targetLang") else ""
|
||||
self.audio = translation.getAttribute("audio") if translation.hasAttribute("audio") else ""
|
||||
|
||||
explanationList = translation_xml.querySelectorAll("explanationList explanation")
|
||||
explanationList = self.original_xml.querySelectorAll("explanationList explanation")
|
||||
for explanation_dom in explanationList:
|
||||
explanation = Explanation()
|
||||
explanation.import_dom(explanation_dom)
|
||||
self.explanationList.append(explanation)
|
||||
|
||||
self.tags = import_label_list("labelList label", translation_xml)
|
||||
explanation_dom.remove()
|
||||
self.tags = import_label_list("labelList label", self.original_xml)
|
||||
|
||||
def view(self, model):
|
||||
elements = []
|
||||
|
|
|
@ -42,15 +42,19 @@ def question(question, current_value):
|
|||
def generic_list_editor(title, element_list_getter):
|
||||
content = [h("p", {}, title)]
|
||||
for slabel in element_list_getter():
|
||||
idAttr = {"data-id": slabel.id} if slabel.id >= 0 else {}
|
||||
content.append(h("label", {}, [
|
||||
h("input.list-adder-input", {"props": {"type": "text", "value": slabel}}, "")]))
|
||||
h("input.list-adder-input", {"props": {"type": "text", "value": slabel.value or slabel}, "attrs": idAttr}, "")]))
|
||||
|
||||
console.log(content)
|
||||
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, element_list_getter)}}, "+"))
|
||||
return content
|
||||
|
||||
def homonymy_editor(title, current_labels):
|
||||
def split_line2(left, right):
|
||||
def split_line2(left, right, labelId):
|
||||
cls = "flex.two{}".format(".double-list-row")
|
||||
return h("div.{}".format(cls), {}, [
|
||||
isId = {"attrs": {"data-id": labelId}} if labelId >= 0 else {}
|
||||
return h("div.{}".format(cls), isId, [
|
||||
h("div.half", {}, left), h("div.half", {}, right)])
|
||||
|
||||
content = [h("p", {}, title)]
|
||||
|
@ -58,19 +62,20 @@ def homonymy_editor(title, current_labels):
|
|||
name = []
|
||||
value = []
|
||||
name.append(h("label", {"attrs": {"for": i}}, "Name:"))
|
||||
name.append(h("input.name-input", {"props": {"type": "text", "value": feature["name"], "id": i}}, ""))
|
||||
name.append(h("input.name-input", {"props": {"type": "text", "value": feature["name"], "id": i, "data-id": feature.id}}, ""))
|
||||
value.append(h("label", {"attrs": {"for": i + "-value"}}, "Value:"))
|
||||
value.append(h("input.value-input", {"props": {"type": "text", "value": feature["value"], "id": i + "-value"}}, ""))
|
||||
|
||||
content.append(split_line2(name, value))
|
||||
content.append(split_line2(name, value, feature.id))
|
||||
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, current_labels)}}, "+"))
|
||||
|
||||
return content
|
||||
|
||||
def explanation_editor(title, current_labels):
|
||||
def split_line2(left, right):
|
||||
def split_line2(left, right, labelId):
|
||||
cls = "flex.two{}".format(".double-list-row")
|
||||
return h("div.{}".format(cls), {}, [
|
||||
isId = {"attrs": {"data-id": labelId}} if labelId >= 0 else {}
|
||||
return h("div.{}".format(cls), isId, [
|
||||
h("div.four-fifth", {}, left), h("div.fifth", {}, right)])
|
||||
|
||||
content = [h("p", {}, title)]
|
||||
|
@ -82,7 +87,7 @@ def explanation_editor(title, current_labels):
|
|||
value.append(h("label", {"attrs": {"for": i + "-value"}}, "Value:"))
|
||||
value.append(h("input.value-input", {"props": {"type": "text", "value": explanation["value"], "id": i + "-value"}}, ""))
|
||||
|
||||
content.append(split_line2(value, language))
|
||||
content.append(split_line2(value, language, explanation.id))
|
||||
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, current_labels)}}, "+"))
|
||||
|
||||
return content
|
||||
|
@ -90,12 +95,13 @@ def explanation_editor(title, current_labels):
|
|||
|
||||
|
||||
def label_list_editor(current_labels, add_label_message_class):
|
||||
def split_line3(left, center, right, is_llr=True):
|
||||
def split_line3(left, center, right, labelId, is_llr=True):
|
||||
isId = {"attrs": {"data-id": labelId}} if labelId >= 0 else {}
|
||||
cls = "flex.three{}".format(".label-list-row" if is_llr else "")
|
||||
return h("div.{}".format(cls), {}, [
|
||||
return h("div.{}".format(cls), isId, [
|
||||
h("span.third", {}, left), h("span.third", {}, center), h("span.third", {}, right)])
|
||||
|
||||
def dropdown_right(label_type, label):
|
||||
def dropdown_right(label_type, label, index):
|
||||
left = h("span.label-type", {}, label_type)
|
||||
|
||||
options = [h("option", {}, [])]
|
||||
|
@ -108,17 +114,16 @@ def label_list_editor(current_labels, add_label_message_class):
|
|||
{"props": {"type": "text", "value": right_value, "placeholder": "drugo"}},
|
||||
[])
|
||||
|
||||
return split_line3(left, center, right)
|
||||
return split_line3(left, center, right, index)
|
||||
|
||||
content = []
|
||||
kontrastivno = False
|
||||
for key, value in current_labels:
|
||||
for key, value, idx in current_labels:
|
||||
# we will show kontrastivno a bit differently
|
||||
if value == "kontrastivno":
|
||||
kontrastivno = True
|
||||
continue
|
||||
|
||||
content.append(dropdown_right(key, value))
|
||||
content.append(dropdown_right(key, value, (idx if idx >= 0 else -1)))
|
||||
|
||||
# add a way to get new element to add to tag list
|
||||
def get_new_label_type():
|
||||
|
|
|
@ -40,7 +40,9 @@ def edit_sense_label(sense):
|
|||
|
||||
def edit_example(example, sense):
|
||||
example_original = example
|
||||
example = example_original.copy()
|
||||
# example = example_original.deepcopy()
|
||||
# example = copy.deepcopy(example)
|
||||
# example.original_xml = example_original.original_xml.cloneNode(True)
|
||||
|
||||
def role_msg(idx, role):
|
||||
return message.msg(message.ExampleRoleChange, example_original, idx, role)
|
||||
|
@ -100,6 +102,7 @@ def edit_variants(entry):
|
|||
|
||||
def edit_homonymy(entry):
|
||||
hget = lambda: entry.copy().homonymy
|
||||
console.log(hget)
|
||||
content = homonymy_editor("Homonymy", hget)
|
||||
return modal_template(content, "Add or remove homonymy features", (message.EditHomonymy,), (message.DeleteHomonymy,))
|
||||
|
||||
|
@ -116,7 +119,7 @@ def edit_entry_labels(entry):
|
|||
|
||||
|
||||
def edit_sense_definition(sense):
|
||||
return modal_template(question("Edit sense definition", sense.definition["indicator"]), "Sense definition", (message.EditSenseDefinition, sense))
|
||||
return modal_template(question("Edit sense definition", sense.definitions[0].value), "Sense definition", (message.EditSenseDefinition, sense))
|
||||
|
||||
|
||||
def edit_comment(comment):
|
||||
|
@ -135,7 +138,7 @@ def do_chosen_examples(example_list, entry):
|
|||
|
||||
options = [h("p", {}, "Choose sense for examples")]
|
||||
for idx, sense in enumerate(entry.senses):
|
||||
text = "{}: {}".format(idx + 1, sense.definition["indicator"])
|
||||
text = "{}: {}".format(idx + 1, sense.definitions[0].value)
|
||||
id_ = "choose-example-{}".format(idx)
|
||||
|
||||
props = {"type": "radio", "name": "choose-example"}
|
||||
|
@ -185,6 +188,6 @@ def ske_list(search_term, data, page_num, senses, ske_kinds):
|
|||
h("div.flex.three", {}, [
|
||||
h("span.third", {}, "Vstavi v:"),
|
||||
h("select#ske-sense-select.two-third", {}, [ h("option", {}, "{} {}".format(
|
||||
idx + 1, sense.definition["indicator"])) for idx, sense in enumerate(senses)])])]
|
||||
idx + 1, sense.definitions[0].value)) for idx, sense in enumerate(senses)])])]
|
||||
|
||||
return modal_template(contents, "SKE", (message.SkeInsert, data))
|
||||
|
|
Loading…
Reference in New Issue
Block a user