|
|
|
@ -59,7 +59,8 @@ class SkeCollocation:
|
|
|
|
|
def __init__(self, data):
|
|
|
|
|
self.word = data.word
|
|
|
|
|
self.frequency = data.count
|
|
|
|
|
self.structure_name, self.structure_id = convert_structure(data.gramrel, data.lempos)
|
|
|
|
|
self.gramrel = data.gramrel
|
|
|
|
|
self.structure_name, self.structure, self.structure_id = convert_structure(data.gramrel, data.lempos)
|
|
|
|
|
|
|
|
|
|
self.other = {"score": data.score, "cm": data.cm}
|
|
|
|
|
|
|
|
|
@ -144,7 +145,22 @@ class SkeModal(ClickMessage):
|
|
|
|
|
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
|
|
|
|
|
match_gf2_examples(data, page_num, search_term, ske_index)
|
|
|
|
|
|
|
|
|
|
elif type(data[0]) is SkeCollocation:
|
|
|
|
|
# filtering, grouping and sorting data
|
|
|
|
|
data.sort(key= lambda x: float(x.other["score"]), reverse=True)
|
|
|
|
|
_data = []
|
|
|
|
|
while len(data) > 0:
|
|
|
|
|
max_item = data.pop(0) # max(data, key= lambda x: x.other["score"])
|
|
|
|
|
_data.append(max_item)
|
|
|
|
|
for item in data:
|
|
|
|
|
if "N/A" in item.structure_name:
|
|
|
|
|
data.remove(item)
|
|
|
|
|
elif item.structure_name.strip() == max_item.structure_name.strip():
|
|
|
|
|
_data.append(item)
|
|
|
|
|
for delete_item in _data:
|
|
|
|
|
if delete_item in data:
|
|
|
|
|
data.remove(delete_item)
|
|
|
|
|
data = _data
|
|
|
|
|
model.modal_set(lambda: modals.ske_list(
|
|
|
|
|
search_term, data, page_num, model.entry.senses, model.ske.request_kinds))
|
|
|
|
|
|
|
|
|
@ -238,7 +254,7 @@ class SkeInsert(DataChgClickMessage):
|
|
|
|
|
|
|
|
|
|
lex_mid = ComponentLexeme()
|
|
|
|
|
lex_mid.text = example["mid"]
|
|
|
|
|
lex_mid.role = "collocation"
|
|
|
|
|
lex_mid.role = "headword"
|
|
|
|
|
|
|
|
|
|
lex_right = ComponentLexeme()
|
|
|
|
|
lex_right.text = example["right"]
|
|
|
|
@ -257,17 +273,45 @@ class SkeInsert(DataChgClickMessage):
|
|
|
|
|
new_collocation.inner.other_attributes["frequency"] = example.frequency
|
|
|
|
|
new_collocation.inner.type = "collocation"
|
|
|
|
|
|
|
|
|
|
lex_left = ComponentLexeme()
|
|
|
|
|
lex_left.text = ""
|
|
|
|
|
lex_left.role = None
|
|
|
|
|
|
|
|
|
|
lex_mid = ComponentLexeme()
|
|
|
|
|
lex_mid.text = example.word
|
|
|
|
|
lex_mid.role = "collocation"
|
|
|
|
|
|
|
|
|
|
lex_right = ComponentLexeme()
|
|
|
|
|
lex_right.text = ""
|
|
|
|
|
lex_right.role = None
|
|
|
|
|
headword = document.getElementById("ske-search").value
|
|
|
|
|
lexemes = []
|
|
|
|
|
structure_name = example.structure_name.split("-")
|
|
|
|
|
gramrel = example.gramrel.split("_")
|
|
|
|
|
structure = example.structure.split(" ")
|
|
|
|
|
structure.append("") # Bad fix: we have to add something for structure l-gg-ggn
|
|
|
|
|
|
|
|
|
|
for i in range(len(structure_name)):
|
|
|
|
|
lex = ComponentLexeme()
|
|
|
|
|
structure[i] = structure[i].replace("Inf-", "")
|
|
|
|
|
|
|
|
|
|
# take care of negations "ne"
|
|
|
|
|
if "Neg-" in structure[i]:
|
|
|
|
|
structure[i] = structure[i].replace("Neg-", "")
|
|
|
|
|
negation_flag = True
|
|
|
|
|
n_lex = ComponentLexeme()
|
|
|
|
|
n_lex.text = "ne"
|
|
|
|
|
n_lex.role = "other"
|
|
|
|
|
lexemes.append(n_lex)
|
|
|
|
|
|
|
|
|
|
if structure[i] is "":
|
|
|
|
|
continue # skipping bcs of fix
|
|
|
|
|
elif "Vez-gbz" in structure[i]:
|
|
|
|
|
lex.text = "je"
|
|
|
|
|
lex.role = "other"
|
|
|
|
|
elif structure_name[i] in ["d", "vd", "zp"]:
|
|
|
|
|
lex.text = gramrel[i]
|
|
|
|
|
lex.text = lex.text.replace("-d", "").replace("%", "")
|
|
|
|
|
lex.role = "other"
|
|
|
|
|
elif structure_name[i] is "vp":
|
|
|
|
|
lex.text = structure[i]
|
|
|
|
|
lex.role = "other"
|
|
|
|
|
elif structure[i][0] in ["S", "G", "P", "R"]:
|
|
|
|
|
lex.text = headword
|
|
|
|
|
lex.role = "headword"
|
|
|
|
|
else:
|
|
|
|
|
lex.text = example.word
|
|
|
|
|
lex.role = "collocate"
|
|
|
|
|
lexemes.append(lex)
|
|
|
|
|
|
|
|
|
|
new_collocation.components.extend([lex_left, lex_mid, lex_right])
|
|
|
|
|
new_collocation.components.extend(lexemes)
|
|
|
|
|
return new_collocation
|
|
|
|
|