6 Commits

Author SHA1 Message Date
e496d3ef01 changed to @exampleId 2021-04-08 09:11:57 +02:00
matic_t
208f5b0ee8 hide-sense added 2021-03-04 23:27:29 -08:00
matic_t
4abf89868d Merge pull request 'context added to tags' (#15) from mt-additional-xml-shema-support into master
Reviewed-on: #15
2021-02-17 11:54:56 +00:00
matic_t
fdda76c6f9 context added to tags 2021-02-01 04:40:24 -08:00
matic_t
b843920119 Merge pull request 'Fixed display for explanation - v4.1' (#14) from mt-definition-list-ui into master
Reviewed-on: #14
2020-12-05 14:48:38 +00:00
matic_t
6da81807df Merge pull request 'Fixed display for definition - v4.1' (#13) from mt-definition-list-ui into master
Reviewed-on: #13
2020-12-05 14:30:27 +00:00
6 changed files with 43 additions and 18 deletions

View File

@@ -269,7 +269,7 @@ class SkeInsert(DataChgClickMessage):
def _as_corpus_example(self, example):
new_example = Example()
new_example.inner = CorpusExample()
new_example.inner.other_attributes["example_id"] = example.s_id
new_example.inner.other_attributes["exampleId"] = example.s_id
new_example.inner.cluster = ExampleClusters.first_empty_cluster()
lex_left = ComponentLexeme()

View File

@@ -119,7 +119,13 @@ class Entry(Data):
if len(self.labels) == 0:
view_buttons.append(buttons[2])
else:
labels = ", ".join([clean_label(val) for _, val in self.labels])
labels = ""
for key, val in self.labels:
if key == "SKRIJ POMEN" and val == "Skrij":
labels = "SKRIJ POMEN, " + labels
else:
labels += clean_label(val) + ", "
labels = labels[:-2]
view_table.append((buttons[2], labels))
if self.comment == "":

View File

@@ -5,10 +5,15 @@ class CorpusExample:
self.other_attributes = {}
def import_xml(self, example_xml):
for oth_attr in ["example_id", "modified", "lexical_unit_id", "audio"]:
for oth_attr in ["exampleId", "modified", "lexical_unit_id", "audio"]:
if example_xml.hasAttribute(oth_attr):
self.other_attributes[oth_attr] = example_xml.getAttribute(oth_attr)
# this is a quick fix. when all data has been updated from @example_id to @exampleId, you can remove this
if oth_attr is "exampleId":
if example_xml.hasAttribute("example_id"):
self.other_attributes[oth_attr] = example_xml.getAttribute("example_id")
def export(self, doc, modified):
result = doc.createElement("corpusExample")
if modified:

View File

@@ -22,7 +22,9 @@ class Example(Data):
# removes space from last component if multiword example
def check_multiword_components(self):
if self.is_multiword():
self.components[len(self.components) - 1].no_space = ComponentLexeme.LAST_COMPONENT_SPACE
# .no_space breaks if it's undefined
if self.components[len(self.components) - 1] != None:
self.components[len(self.components) - 1].no_space = ComponentLexeme.LAST_COMPONENT_SPACE
@staticmethod
def new_multiword():

View File

@@ -8,8 +8,10 @@ TAGS = {
"latinsko": [],
"razmerje": ["približek", "sinonim", "antonim"],
"semantično": [],
"kontekstualna": [],
"Polno angleško": [],
"Blagovna znamka": []
"Blagovna znamka": [],
"SKRIJ POMEN": ["Skrij"]
}
SLO2ENG_TAGS = {
@@ -23,8 +25,10 @@ SLO2ENG_TAGS = {
"latinsko": "latin",
"razmerje": "relation",
"semantično": "semantic",
"kontekstualna": "context",
"Polno angleško": "English-full",
"Blagovna znamka": "trademark"
"Blagovna znamka": "trademark",
"SKRIJ POMEN": "hide-sense",
}
ENG2SLO_TAGS = { value: key for key, value in SLO2ENG_TAGS.items() }
@@ -40,7 +44,7 @@ def import_label_list(selector, xml_element):
for tag_xml in 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))
return result
@@ -52,14 +56,14 @@ def import_tag(key, value):
# simmilar for "stilne"
# if english, than translate and change style-xxx for stilne
# for value, just handle if some bad "-- xxx" stuff is in xml
if key in SLO2ENG_TAGS:
pass
elif key in ("stilne", "style"):
key = "stilne"
elif key in ENG2SLO_TAGS:
key = ENG2SLO_TAGS[key]
# handle stilne-xxx stuff
if "-" in key:
key = key.split("-")[0]
@@ -67,15 +71,18 @@ def import_tag(key, value):
window.console.log("Uknown tag :(", key, value)
# using some default
key = TAGS.keys()[0]
# this should not happen, but maybe there was a bug...
value = value.replace("--", "").strip()
if key == "SKRIJ POMEN" and value == "true":
value = "Skrij"
for tag_key in TAGS.keys():
for possible_value in TAGS[tag_key]:
if value == possible_value or "-- " + value == possible_value:
return key, possible_value
# not found, must be manually inputted
return key, value
@@ -85,18 +92,19 @@ def export_tag(key, value):
arr = TAGS["stilne"]
key = "style"
value_idx = arr.index(value)
if value_idx >= 0:
for sec_slo, sec_eng in reversed(STYLE_SECTIONS):
idx = arr.index(sec_slo)
if idx < value_idx:
key = "style-" + sec_eng
break
else:
key = SLO2ENG_TAGS[key]
if key == "hide-sense":
value = "true"
value = value.replace("--", "").strip()
return key, value

View File

@@ -132,7 +132,11 @@ def label_list_editor(current_labels, add_label_message_class):
center = h("select.label-value", {}, options)
right_value = label if label not in TAGS[label_type] else ""
right_value = "blagovna znamka" if label_type == 'Blagovna znamka' else right_value
if label_type == "Blagovna znamka":
right_value = "blagovna znamka"
elif label_type == "SKRIJ POMEN":
right_value = "Skrij"
# right_value = "blagovna znamka" if label_type == 'Blagovna znamka' else right_value
right = h("input.label-value-other",
{"props": {"type": "text", "value": right_value, "placeholder": "drugo"}},
[])