homonymy basic implementation

mt-homonymy-support
matic_t 4 years ago
parent e37cf198cf
commit a22490c0fc

@ -4,7 +4,12 @@
<head>
<status>LBS</status>
<headword>
<lemma>aplikativen</lemma>
<lemma>aplikativen3</lemma>
<homonymy>
<homonymyFeature name="pronunciation">bolníšnica</homonymyFeature>
<homonymyFeature name="blahblah">xyz</homonymyFeature>
<homonymyFeature name="bluhbluh">abc</homonymyFeature>
</homonymy>
</headword>
<grammar>
<category>pridevnik</category>

@ -11,7 +11,6 @@ def export_to_xml(model):
def export_entry(entry):
parser = __new__(DOMParser())
doc = parser.parseFromString("<entry />", "text/xml")
entry_xml = doc.firstChild
# create head
@ -30,6 +29,14 @@ def export_entry(entry):
headword.appendChild(headword_lemma)
head.appendChild(headword)
homonyms = doc.createElement("homonymy")
headword.appendChild(homonyms)
for h in entry.homonymy:
homonymy = doc.createElement("homonymyFeature")
homonymy.textContent = h
homonyms.appendChild(homonymy)
# if({}) works uncorrectly in transcrypt
if len(entry.lexical_unit) > 0:
lexunit = doc.createElement("lexicalUnit")

@ -1,11 +1,11 @@
from message.simple_messages import NoReset, Reset, ModalNotOkClose, ClickMessage, DataChgClickMessage, KeyboardPress, NoAction
from message.translation_edit import EditTranslation, MoveRight, MoveLeft, BinTranslation
from message.show_messages import ShowEntryLabelsEdit, ShowEditTranslation, ShowSenseLabelEdit, ShowSenseDefinitionEdit, ShowCommentEdit, ShowAddTranslation, ShowExampleEdit, ShowVariantsEdit, ShowRelatedEntriesEdit
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, AddExampleTranslation, DoChosenExamples, AddToLabelList, AddToGenericList, EditVariants, EditRelatedEntries, EditEntryLabels, ExampleClusterEdit, ExampleClusterAdd
from message.show_messages import ShowEntryLabelsEdit, ShowEditTranslation, ShowSenseLabelEdit, ShowSenseDefinitionEdit, ShowCommentEdit, ShowAddTranslation, ShowExampleEdit, ShowVariantsEdit, ShowHomonymyEdit, ShowRelatedEntriesEdit
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, AddExampleTranslation, DoChosenExamples, AddToLabelList, AddToGenericList, EditVariants, EditHomonymy, EditRelatedEntries, EditEntryLabels, ExampleClusterEdit, ExampleClusterAdd
from message.show_menu import ShowTranslationMenu, ShowSenseMenu, ShowExampleMenu
from message.sense_edit import SenseMoveUp, SenseMoveDown, SenseBin, AddMultiwordExample
from message.example_edit import ExampleMoveUp, ExampleMoveDown, ExampleBin, ExampleRoleChange, ExampleComponentSpace, ExampleComponentAdd, ExampleComponentRemove, EditExampleText, ToggleExamples, ToggleClusters
from message.delete_messages import DeleteComment, DeleteVariants, DeleteRelatedEntries, DeleteEntryLabels
from message.delete_messages import DeleteComment, DeleteVariants, DeleteHomonymy, DeleteRelatedEntries, DeleteEntryLabels
from message.ske_messages import ShowSkeModal, SearchInSkeModal, SkeInsert
from message.message import msg, delayed_msg

@ -18,6 +18,14 @@ class DeleteRelatedEntries(DeleteVariants):
pass
class DeleteHomonymy(NoReset):
def update_model(self, model):
for el in document.getElementsByClassName("list-adder-input"):
el.value = ""
class DeleteEntryLabels(NoReset):
def update_model(self, model):
for sel in document.getElementsByClassName("label-value"):

@ -30,6 +30,12 @@ class ShowVariantsEdit(ClickMessage):
model.modal_set(lambda: modals.edit_variants(model.entry))
class ShowHomonymyEdit(ClickMessage):
def update_model(self, model):
model.entry.make_copy()
model.modal_set(lambda: modals.edit_homonymy(model.entry))
class ShowRelatedEntriesEdit(ClickMessage):
def update_model(self, model):
model.entry.make_copy()

@ -88,6 +88,11 @@ class EditVariants(Message):
variants = common_accessors.generic_list_getter()
model.entry.variants = variants
class EditHomonymy(Message):
def update_model(self, model):
homonymy = common_accessors.generic_list_getter()
model.entry.homonymy = homonymy
class EditRelatedEntries(Message):
def update_model(self, model):

@ -12,6 +12,7 @@ class Entry(Data):
def __init__(self):
self.status = ""
self.headword = ""
self.homonymy = []
self.headword_type = None
self.grammar = ""
self.comment = ""
@ -25,6 +26,7 @@ class Entry(Data):
def import_xml(self, entry_xml):
status = entry_xml.querySelector("head status")
headword = entry_xml.querySelector("head headword lemma")
grammar = entry_xml.querySelector("head grammar category")
comment = entry_xml.querySelector("head comment")
@ -34,6 +36,7 @@ class Entry(Data):
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 = [v.textContent for v in entry_xml.querySelectorAll("head headword homonymy homonymyFeature ")]
self.related_entries = [re.textContent for re in entry_xml.querySelectorAll("head relatedEntryList relatedEntry")]
lex_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
@ -80,7 +83,8 @@ class Entry(Data):
h("button.normal", clk(M.ShowVariantsEdit), "Variante"),
h("button.success", clk(M.ShowRelatedEntriesEdit), "Povezano"),
h("button.success", clk(M.ShowEntryLabelsEdit), "Oznake"),
h("button.normal", clk(M.ShowCommentEdit), "Opombe")]
h("button.normal", clk(M.ShowCommentEdit), "Opombe"),
h("button.normal", clk(M.ShowHomonymyEdit), "Homonomije"),]
view_buttons = []
view_table = []
@ -90,6 +94,11 @@ class Entry(Data):
else:
view_table.append((buttons[0], ", ".join(self.variants)))
if len(self.homonymy) == 0:
view_buttons.append(buttons[4])
else:
view_table.append((buttons[4], ", ".join(self.homonymy)))
if len(self.related_entries) == 0:
view_buttons.append(buttons[1])
else:

@ -99,6 +99,13 @@ def edit_variants(entry):
return modal_template(content, "Add or remove variants", (message.EditVariants,), (message.DeleteVariants,))
def edit_homonymy(entry):
console.log(entry)
hget = lambda: entry.copy().homonymy
content = generic_list_editor("Homonymy", hget)
return modal_template(content, "Add or remove homonymy features", (message.EditHomonymy,), (message.DeleteHomonymy,))
def edit_related_entries(entry):
reget = lambda: entry.copy().related_entries
content = generic_list_editor("Related entries", reget)

Loading…
Cancel
Save