mt-homonymy-support #2
@ -4,10 +4,10 @@
|
||||
#############################################################################
|
||||
|
||||
# Alter these variables
|
||||
#USERNAME= vps_sign_in(probably name@lexonomy.cjvt.si
|
||||
#VPS_PASSWORD= vps password
|
||||
#VPS_USERNAME= user name inside vps(probably name from @lexonomy)
|
||||
#API_KEY= $(cat path/to/api/token/file)
|
||||
#USERNAME=vps_sign_in(probably name@lexonomy.cjvt.si
|
||||
#VPS_PASSWORD=vps password
|
||||
#VPS_USERNAME=user name inside vps(probably name from @lexonomy)
|
||||
#API_KEY=$(cat path/to/api/token/file)
|
||||
|
||||
# Exit if no argument is passed on run
|
||||
if [[ -z "$1" ]]; then
|
||||
@ -24,4 +24,4 @@ tar czf - ./config.json ./bundle.js ./local.js ./main.css ./main.html | ssh $USE
|
||||
|
||||
# Create a simlink on VPS that will enable specific plugin on https://lexonomy.cjvt.si/
|
||||
# Routes must be absolute or it doesn't work.
|
||||
ssh -t $USERNAME -p $VPS_PASSWORD "sudo ln -s /home/$VPS_USERNAME/plugins/$PLUGIN_NAME /home/ozbolt/plugins/$PLUGIN_NAME"
|
||||
ssh -t $USERNAME -p $VPS_PASSWORD "sudo -s unlink /home/ozbolt/plugins/$PLUGIN_NAME || true && sudo ln -s /home/$VPS_USERNAME/plugins/$PLUGIN_NAME /home/ozbolt/plugins/$PLUGIN_NAME"
|
||||
|
@ -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,17 @@ def export_entry(entry):
|
||||
headword.appendChild(headword_lemma)
|
||||
head.appendChild(headword)
|
||||
|
||||
homonymy = doc.createElement("homonymy")
|
||||
headword.appendChild(homonymy)
|
||||
|
||||
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"])
|
||||
homonymy.appendChild(feature)
|
||||
|
||||
|
||||
# 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
|
||||
|
@ -9,6 +9,21 @@ def generic_list_getter():
|
||||
result.append(result_candidate)
|
||||
return result
|
||||
|
||||
# Formats data from inputs to name-value objects
|
||||
def homonymy_list_getter():
|
||||
result = []
|
||||
for row in document.getElementsByClassName("label-list-row"):
|
||||
value = row.querySelector(".value-input").value
|
||||
name = row.querySelector(".name-input").value
|
||||
|
||||
if ("" in [name, value]):
|
||||
continue
|
||||
|
||||
result.append({"name": name, "value": value})
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def label_list_getter():
|
||||
result = []
|
||||
for row in document.getElementsByClassName("label-list-row"):
|
||||
|
@ -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.homonymy_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,15 +26,16 @@ 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")
|
||||
|
||||
self.status = status.textContent if status else ""
|
||||
self.headword = headword.textContent if headword else ""
|
||||
self.headword_type = headword.getAttribute("type") if headword 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")]
|
||||
|
||||
lex_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
|
||||
@ -80,7 +82,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 +93,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((h["name"] + ": " + h.value) for h in self.homonymy)))
|
||||
|
||||
if len(self.related_entries) == 0:
|
||||
view_buttons.append(buttons[1])
|
||||
else:
|
||||
|
@ -47,6 +47,25 @@ def generic_list_editor(title, element_list_getter):
|
||||
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):
|
||||
cls = "flex.two{}".format(".label-list-row")
|
||||
return h("div.{}".format(cls), {}, [
|
||||
h("div.half", {}, left), h("div.half", {}, right)])
|
||||
|
||||
content = [h("p", {}, title)]
|
||||
for i, feature in enumerate(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}}, ""))
|
||||
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(h("button", {"on": {"click": message.msg(message.AddToGenericList, current_labels)}}, "+"))
|
||||
|
||||
return content
|
||||
|
||||
def label_list_editor(current_labels, add_label_message_class):
|
||||
def split_line3(left, center, right, is_llr=True):
|
||||
|
@ -99,6 +99,12 @@ def edit_variants(entry):
|
||||
return modal_template(content, "Add or remove variants", (message.EditVariants,), (message.DeleteVariants,))
|
||||
|
||||
|
||||
def edit_homonymy(entry):
|
||||
hget = lambda: entry.copy().homonymy
|
||||
content = homonymy_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…
Reference in New Issue
Block a user