9 Commits

7 changed files with 51 additions and 23 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

@@ -37,18 +37,21 @@ class Sense(Data):
def view(self, model, sense_num):
examples = [example.view(model, self) for example in self.examples]
definition = ""
indicator = None
explanation = None
for x in self.definitions:
if x["type"] == "indicator":
definition = x.value
break
if indicator is None and x["type"] == "indicator":
indicator = x.value
if explanation is None and x["type"] == "explanation":
explanation = x.value
result = h("div.elm-div", {}, [
h("div.sense-num", {"on": {"click": M.msg(M.ShowSenseMenu, self)}}, str(sense_num + 1)),
h("div.sense", {}, [
h("span.sense-label-list", { "on": { "click": M.msg(M.ShowSenseLabelEdit, self) }}, [
h("span.sense-label", {}, clean_label(slabel)) for _, slabel in self.labels ]),
h("span.sense-definition", { "on": { "click": M.msg(M.ShowSenseDefinitionEdit, self) }}, definition),
h("span.sense-definition", { "on": { "click": M.msg(M.ShowSenseDefinitionEdit, self) }}, indicator),
h("div", {}, "Razlaga: " + explanation) if explanation else None,
h("div", {}, View.view_translations(self.translations, self, model)),
h("div", {}, examples)])])
return result

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() }
@@ -71,6 +75,9 @@ def import_tag(key, value):
# 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:
@@ -95,7 +102,8 @@ def export_tag(key, value):
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"}},
[])