hide-sense added

This commit is contained in:
matic_t 2021-03-04 23:27:29 -08:00
parent 4abf89868d
commit 208f5b0ee8
4 changed files with 34 additions and 16 deletions

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

@ -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

@ -10,7 +10,8 @@ TAGS = {
"semantično": [],
"kontekstualna": [],
"Polno angleško": [],
"Blagovna znamka": []
"Blagovna znamka": [],
"SKRIJ POMEN": ["Skrij"]
}
SLO2ENG_TAGS = {
@ -26,7 +27,8 @@ SLO2ENG_TAGS = {
"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() }
@ -42,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
@ -54,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]
@ -69,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
@ -87,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"}},
[])