Compare commits
2 Commits
mt-homonym
...
lk-colloca
| Author | SHA1 | Date | |
|---|---|---|---|
| a7f85accce | |||
| 3926d1a199 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -10,5 +10,5 @@ build/*
|
|||||||
# using kdev4, works fairly nicely!
|
# using kdev4, works fairly nicely!
|
||||||
.kdev4
|
.kdev4
|
||||||
**/*.kdev4
|
**/*.kdev4
|
||||||
|
remote
|
||||||
|
|
||||||
|
|||||||
@@ -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/
|
# Create a simlink on VPS that will enable specific plugin on https://lexonomy.cjvt.si/
|
||||||
# Routes must be absolute or it doesn't work.
|
# Routes must be absolute or it doesn't work.
|
||||||
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"
|
ssh -t $USERNAME -p $VPS_PASSWORD "sudo ln -s /home/$VPS_USERNAME/plugins/$PLUGIN_NAME /home/ozbolt/plugins/$PLUGIN_NAME"
|
||||||
|
|||||||
@@ -4,12 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<status>LBS</status>
|
<status>LBS</status>
|
||||||
<headword>
|
<headword>
|
||||||
<lemma>aplikativen3</lemma>
|
<lemma>aplikativen</lemma>
|
||||||
<homonymy>
|
|
||||||
<homonymyFeature name="pronunciation">bolníšnica</homonymyFeature>
|
|
||||||
<homonymyFeature name="blahblah">xyz</homonymyFeature>
|
|
||||||
<homonymyFeature name="bluhbluh">abc</homonymyFeature>
|
|
||||||
</homonymy>
|
|
||||||
</headword>
|
</headword>
|
||||||
<grammar>
|
<grammar>
|
||||||
<category>pridevnik</category>
|
<category>pridevnik</category>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ def export_to_xml(model):
|
|||||||
def export_entry(entry):
|
def export_entry(entry):
|
||||||
parser = __new__(DOMParser())
|
parser = __new__(DOMParser())
|
||||||
doc = parser.parseFromString("<entry />", "text/xml")
|
doc = parser.parseFromString("<entry />", "text/xml")
|
||||||
|
|
||||||
entry_xml = doc.firstChild
|
entry_xml = doc.firstChild
|
||||||
|
|
||||||
# create head
|
# create head
|
||||||
@@ -29,17 +30,6 @@ def export_entry(entry):
|
|||||||
headword.appendChild(headword_lemma)
|
headword.appendChild(headword_lemma)
|
||||||
head.appendChild(headword)
|
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({}) works uncorrectly in transcrypt
|
||||||
if len(entry.lexical_unit) > 0:
|
if len(entry.lexical_unit) > 0:
|
||||||
lexunit = doc.createElement("lexicalUnit")
|
lexunit = doc.createElement("lexicalUnit")
|
||||||
|
|||||||
@@ -34,12 +34,23 @@ def build_structure_conversions():
|
|||||||
structure_conversions.append((__new__(RegExp(vfrom, 'u')), vto_name, vto_id))
|
structure_conversions.append((__new__(RegExp(vfrom, 'u')), vto_name, vto_id))
|
||||||
|
|
||||||
|
|
||||||
def convert_structure(structure):
|
def convert_structure(structure, type):
|
||||||
if structure_conversions is None:
|
if structure_conversions is None:
|
||||||
build_structure_conversions()
|
build_structure_conversions()
|
||||||
|
|
||||||
for vfrom, vto_name, vto_id in structure_conversions:
|
for vfrom, vto_name, vto_id in structure_conversions:
|
||||||
match = structure.match(vfrom)
|
match = structure.match(vfrom)
|
||||||
|
# fix for ids 65, 66, 67 which instead matched with 64
|
||||||
|
if match and vto_id == '64' and '-s' in type:
|
||||||
|
vto_name = 's0-vp-s0'
|
||||||
|
vto_id = '65'
|
||||||
|
elif match and vto_id == '64' and '-g' in type:
|
||||||
|
vto_name = 'gg-vp-gg'
|
||||||
|
vto_id = '66'
|
||||||
|
elif match and vto_id == '64' and '-r' in type:
|
||||||
|
vto_name = 'r-vp-r'
|
||||||
|
vto_id = '67'
|
||||||
|
|
||||||
if match:
|
if match:
|
||||||
# we need to remove replace alias here as we want to use javascript's one
|
# we need to remove replace alias here as we want to use javascript's one
|
||||||
__pragma__('noalias', 'replace')
|
__pragma__('noalias', 'replace')
|
||||||
@@ -49,4 +60,4 @@ def convert_structure(structure):
|
|||||||
return result, vto_id
|
return result, vto_id
|
||||||
|
|
||||||
window.console.log("Unknown structure: ", structure)
|
window.console.log("Unknown structure: ", structure)
|
||||||
return None
|
return 'N/A', '/'
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
from message.simple_messages import NoReset, Reset, ModalNotOkClose, ClickMessage, DataChgClickMessage, KeyboardPress, NoAction
|
from message.simple_messages import NoReset, Reset, ModalNotOkClose, ClickMessage, DataChgClickMessage, KeyboardPress, NoAction
|
||||||
from message.translation_edit import EditTranslation, MoveRight, MoveLeft, BinTranslation
|
from message.translation_edit import EditTranslation, MoveRight, MoveLeft, BinTranslation
|
||||||
from message.show_messages import ShowEntryLabelsEdit, ShowEditTranslation, ShowSenseLabelEdit, ShowSenseDefinitionEdit, ShowCommentEdit, ShowAddTranslation, ShowExampleEdit, ShowVariantsEdit, ShowHomonymyEdit, ShowRelatedEntriesEdit
|
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, EditHomonymy, EditRelatedEntries, EditEntryLabels, ExampleClusterEdit, ExampleClusterAdd
|
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, AddExampleTranslation, DoChosenExamples, AddToLabelList, AddToGenericList, EditVariants, EditRelatedEntries, EditEntryLabels, ExampleClusterEdit, ExampleClusterAdd
|
||||||
from message.show_menu import ShowTranslationMenu, ShowSenseMenu, ShowExampleMenu
|
from message.show_menu import ShowTranslationMenu, ShowSenseMenu, ShowExampleMenu
|
||||||
from message.sense_edit import SenseMoveUp, SenseMoveDown, SenseBin, AddMultiwordExample
|
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.example_edit import ExampleMoveUp, ExampleMoveDown, ExampleBin, ExampleRoleChange, ExampleComponentSpace, ExampleComponentAdd, ExampleComponentRemove, EditExampleText, ToggleExamples, ToggleClusters
|
||||||
from message.delete_messages import DeleteComment, DeleteVariants, DeleteHomonymy, DeleteRelatedEntries, DeleteEntryLabels
|
from message.delete_messages import DeleteComment, DeleteVariants, DeleteRelatedEntries, DeleteEntryLabels
|
||||||
from message.ske_messages import ShowSkeModal, SearchInSkeModal, SkeInsert
|
from message.ske_messages import ShowSkeModal, SearchInSkeModal, SkeInsert
|
||||||
|
|
||||||
from message.message import msg, delayed_msg
|
from message.message import msg, delayed_msg
|
||||||
|
|||||||
@@ -9,21 +9,6 @@ def generic_list_getter():
|
|||||||
result.append(result_candidate)
|
result.append(result_candidate)
|
||||||
return result
|
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():
|
def label_list_getter():
|
||||||
result = []
|
result = []
|
||||||
for row in document.getElementsByClassName("label-list-row"):
|
for row in document.getElementsByClassName("label-list-row"):
|
||||||
|
|||||||
@@ -18,14 +18,6 @@ class DeleteRelatedEntries(DeleteVariants):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteHomonymy(NoReset):
|
|
||||||
def update_model(self, model):
|
|
||||||
for el in document.getElementsByClassName("list-adder-input"):
|
|
||||||
el.value = ""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteEntryLabels(NoReset):
|
class DeleteEntryLabels(NoReset):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
for sel in document.getElementsByClassName("label-value"):
|
for sel in document.getElementsByClassName("label-value"):
|
||||||
|
|||||||
@@ -30,12 +30,6 @@ class ShowVariantsEdit(ClickMessage):
|
|||||||
model.modal_set(lambda: modals.edit_variants(model.entry))
|
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):
|
class ShowRelatedEntriesEdit(ClickMessage):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
model.entry.make_copy()
|
model.entry.make_copy()
|
||||||
|
|||||||
@@ -88,11 +88,6 @@ class EditVariants(Message):
|
|||||||
variants = common_accessors.generic_list_getter()
|
variants = common_accessors.generic_list_getter()
|
||||||
model.entry.variants = variants
|
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):
|
class EditRelatedEntries(Message):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class SkeExample:
|
|||||||
self.mid = ""
|
self.mid = ""
|
||||||
self.s_id = ""
|
self.s_id = ""
|
||||||
self.gf2_good = None
|
self.gf2_good = None
|
||||||
|
self.gf2_check = False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fromLine(line):
|
def fromLine(line):
|
||||||
@@ -58,15 +59,7 @@ class SkeCollocation:
|
|||||||
def __init__(self, data):
|
def __init__(self, data):
|
||||||
self.word = data.word
|
self.word = data.word
|
||||||
self.frequency = data.count
|
self.frequency = data.count
|
||||||
|
self.structure_name, self.structure_id = convert_structure(data.gramrel, data.lempos)
|
||||||
info = convert_structure(data.gramrel)
|
|
||||||
if info is None:
|
|
||||||
self.structure_name = None
|
|
||||||
self.structure_id = None
|
|
||||||
else:
|
|
||||||
self.structure_name = info[0]
|
|
||||||
self.structure_id = info[1]
|
|
||||||
|
|
||||||
|
|
||||||
self.other = {"score": data.score, "cm": data.cm}
|
self.other = {"score": data.score, "cm": data.cm}
|
||||||
|
|
||||||
@@ -148,7 +141,7 @@ class SkeModal(ClickMessage):
|
|||||||
elif type(data) is list:
|
elif type(data) is list:
|
||||||
window.console.log(data)
|
window.console.log(data)
|
||||||
# check if gf2 examples are loaded or not
|
# check if gf2 examples are loaded or not
|
||||||
if data[0].gf2_good is None:
|
if not data[0].gf2_check and type(data[0]) is SkeExample:
|
||||||
# we get the data, we have to match it with available data on our gf2 examples API
|
# we get the data, we have to match it with available data on our gf2 examples API
|
||||||
match_gf2_examples(data, page_num, search_term, ske_index)
|
match_gf2_examples(data, page_num, search_term, ske_index)
|
||||||
|
|
||||||
@@ -169,12 +162,18 @@ class SkeModalGf2Update(SkeModal):
|
|||||||
example.gf_good = False
|
example.gf_good = False
|
||||||
data_dict[example.s_id] = example
|
data_dict[example.s_id] = example
|
||||||
|
|
||||||
|
bad_response = dict(response_data["bad"])
|
||||||
|
for gf_sid, gf_data in bad_response.items():
|
||||||
|
data_dict[gf_sid].gf2_good = None
|
||||||
|
data_dict[gf_sid].gf2_check = True
|
||||||
|
|
||||||
good_response = dict(response_data["good"])
|
good_response = dict(response_data["good"])
|
||||||
for gf_sid, gf_data in good_response.items():
|
for gf_sid, gf_data in good_response.items():
|
||||||
data_dict[gf_sid].left = gf_data.left
|
data_dict[gf_sid].left = gf_data.left
|
||||||
data_dict[gf_sid].mid = gf_data.mid
|
data_dict[gf_sid].mid = gf_data.mid
|
||||||
data_dict[gf_sid].right = gf_data.right
|
data_dict[gf_sid].right = gf_data.right
|
||||||
data_dict[gf_sid].gf2_good = True
|
data_dict[gf_sid].gf2_good = True
|
||||||
|
data_dict[gf_sid].gf2_check = True
|
||||||
|
|
||||||
# changed data_dict, now we can redraw!
|
# changed data_dict, now we can redraw!
|
||||||
# just let it do its thing in update_model
|
# just let it do its thing in update_model
|
||||||
@@ -225,6 +224,8 @@ class SkeInsert(DataChgClickMessage):
|
|||||||
console.log("You really should not be here, my lady")
|
console.log("You really should not be here, my lady")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
model.reset()
|
||||||
|
|
||||||
def _as_corpus_example(self, example):
|
def _as_corpus_example(self, example):
|
||||||
new_example = Example()
|
new_example = Example()
|
||||||
new_example.inner = CorpusExample()
|
new_example.inner = CorpusExample()
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ class Entry(Data):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.status = ""
|
self.status = ""
|
||||||
self.headword = ""
|
self.headword = ""
|
||||||
self.homonymy = []
|
|
||||||
self.headword_type = None
|
self.headword_type = None
|
||||||
self.grammar = ""
|
self.grammar = ""
|
||||||
self.comment = ""
|
self.comment = ""
|
||||||
@@ -26,16 +25,15 @@ class Entry(Data):
|
|||||||
def import_xml(self, entry_xml):
|
def import_xml(self, entry_xml):
|
||||||
status = entry_xml.querySelector("head status")
|
status = entry_xml.querySelector("head status")
|
||||||
headword = entry_xml.querySelector("head headword lemma")
|
headword = entry_xml.querySelector("head headword lemma")
|
||||||
|
|
||||||
grammar = entry_xml.querySelector("head grammar category")
|
grammar = entry_xml.querySelector("head grammar category")
|
||||||
comment = entry_xml.querySelector("head comment")
|
comment = entry_xml.querySelector("head comment")
|
||||||
|
|
||||||
self.status = status.textContent if status else ""
|
self.status = status.textContent if status else ""
|
||||||
self.headword = headword.textContent if headword else ""
|
self.headword = headword.textContent if headword else ""
|
||||||
self.headword_type = headword.getAttribute("type") if headword else None
|
self.headword_type = headword.getAttribute("type") if headword else None
|
||||||
self.grammar = grammar.textContent if grammar else ""
|
self.grammar = grammar.textContent if grammar else ""
|
||||||
self.comment = comment.textContent if comment else ""
|
self.comment = comment.textContent if comment else ""
|
||||||
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.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_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
|
lex_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
|
||||||
@@ -82,8 +80,7 @@ class Entry(Data):
|
|||||||
h("button.normal", clk(M.ShowVariantsEdit), "Variante"),
|
h("button.normal", clk(M.ShowVariantsEdit), "Variante"),
|
||||||
h("button.success", clk(M.ShowRelatedEntriesEdit), "Povezano"),
|
h("button.success", clk(M.ShowRelatedEntriesEdit), "Povezano"),
|
||||||
h("button.success", clk(M.ShowEntryLabelsEdit), "Oznake"),
|
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_buttons = []
|
||||||
view_table = []
|
view_table = []
|
||||||
@@ -93,11 +90,6 @@ class Entry(Data):
|
|||||||
else:
|
else:
|
||||||
view_table.append((buttons[0], ", ".join(self.variants)))
|
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:
|
if len(self.related_entries) == 0:
|
||||||
view_buttons.append(buttons[1])
|
view_buttons.append(buttons[1])
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -47,25 +47,6 @@ def generic_list_editor(title, element_list_getter):
|
|||||||
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, element_list_getter)}}, "+"))
|
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, element_list_getter)}}, "+"))
|
||||||
return content
|
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 label_list_editor(current_labels, add_label_message_class):
|
||||||
def split_line3(left, center, right, is_llr=True):
|
def split_line3(left, center, right, is_llr=True):
|
||||||
|
|||||||
@@ -99,12 +99,6 @@ def edit_variants(entry):
|
|||||||
return modal_template(content, "Add or remove variants", (message.EditVariants,), (message.DeleteVariants,))
|
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):
|
def edit_related_entries(entry):
|
||||||
reget = lambda: entry.copy().related_entries
|
reget = lambda: entry.copy().related_entries
|
||||||
content = generic_list_editor("Related entries", reget)
|
content = generic_list_editor("Related entries", reget)
|
||||||
|
|||||||
Reference in New Issue
Block a user