From aca8093ab31fd4c19a8335cdb3f13864196abbcb Mon Sep 17 00:00:00 2001 From: LukeItUp Date: Fri, 17 Jul 2020 10:50:12 +0200 Subject: [PATCH 1/5] Feature#1405 collocation structure --- build/Makefile | 2 +- src/lib/structure_conversions.py | 17 ++++++++++++++--- src/message/ske_messages.py | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/build/Makefile b/build/Makefile index 5113996..9fb0d7a 100644 --- a/build/Makefile +++ b/build/Makefile @@ -31,7 +31,7 @@ all: build build: copy $(CSS_FILE) bundle.js local.js transcrypt: $(RES_PY_FILE) $(TS_BUILD) - transcrypt $(TS_FLAGS) $< + python3 -m transcrypt $(TS_FLAGS) $< bundle.js: transcrypt $(CONV_FILE) cd ..; browserify $(BR_FLAGS) build/$(TS_BUILD)/main.js -o build/bundle.js diff --git a/src/lib/structure_conversions.py b/src/lib/structure_conversions.py index 5e408fc..2dbfec8 100644 --- a/src/lib/structure_conversions.py +++ b/src/lib/structure_conversions.py @@ -34,19 +34,30 @@ def build_structure_conversions(): 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: build_structure_conversions() for vfrom, vto_name, vto_id in structure_conversions: match = structure.match(vfrom) + # fix for ids 65, 66 which matched instead with 64 + if match and vto_id == '64' and '-g' in type: + vto_name = 'gg-vp-gg' + vto_id = '66' + elif match and vto_id == '64' and '-s' in type: + vto_name = 's0-vp-s0' + vto_id = '65' + if match: # we need to remove replace alias here as we want to use javascript's one __pragma__('noalias', 'replace') result = structure.replace(vfrom, vto_name).strip() __pragma__('alias', 'replace', "py_replace") - + + if vto_id == '64': + console.log(structure) + return result, vto_id window.console.log("Unknown structure: ", structure) - return None + return 'N/A', '/' diff --git a/src/message/ske_messages.py b/src/message/ske_messages.py index 6900cdf..9d03c9b 100644 --- a/src/message/ske_messages.py +++ b/src/message/ske_messages.py @@ -58,7 +58,7 @@ class SkeCollocation: def __init__(self, data): self.word = data.word self.frequency = data.count - self.structure_name, self.structure_id = convert_structure(data.gramrel) + self.structure_name, self.structure_id = convert_structure(data.gramrel, data.filterwords) self.other = {"score": data.score, "cm": data.cm} @@ -71,7 +71,7 @@ class SkeCollocation: h("span.grey1", {}, self.other["cm"]), h("span", {}, ","), h("span.grey2", {}, self.structure_name)])] - + def get_parser(ske_index_type): if ske_index_type == 0: -- 2.36.5 From bfad8e3b0657a3fbc83eec65b61f33a9e3acbf44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Kav=C4=8Di=C4=8D?= Date: Fri, 17 Jul 2020 08:58:53 +0000 Subject: [PATCH 2/5] Makefile transcrypt call --- build/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Makefile b/build/Makefile index 9fb0d7a..5113996 100644 --- a/build/Makefile +++ b/build/Makefile @@ -31,7 +31,7 @@ all: build build: copy $(CSS_FILE) bundle.js local.js transcrypt: $(RES_PY_FILE) $(TS_BUILD) - python3 -m transcrypt $(TS_FLAGS) $< + transcrypt $(TS_FLAGS) $< bundle.js: transcrypt $(CONV_FILE) cd ..; browserify $(BR_FLAGS) build/$(TS_BUILD)/main.js -o build/bundle.js -- 2.36.5 From 2b0c82f11b636fd2e55e274cdcd1cdb56bdfa56c Mon Sep 17 00:00:00 2001 From: LukeItUp Date: Fri, 17 Jul 2020 11:19:19 +0200 Subject: [PATCH 3/5] get type from data.lempos --- src/lib/structure_conversions.py | 13 ++++++++----- src/message/ske_messages.py | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/lib/structure_conversions.py b/src/lib/structure_conversions.py index 2dbfec8..782072f 100644 --- a/src/lib/structure_conversions.py +++ b/src/lib/structure_conversions.py @@ -40,13 +40,16 @@ def convert_structure(structure, type): for vfrom, vto_name, vto_id in structure_conversions: match = structure.match(vfrom) - # fix for ids 65, 66 which matched instead with 64 - if match and vto_id == '64' and '-g' in type: - vto_name = 'gg-vp-gg' - vto_id = '66' - elif match and vto_id == '64' and '-s' in type: + # 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: # we need to remove replace alias here as we want to use javascript's one diff --git a/src/message/ske_messages.py b/src/message/ske_messages.py index 9d03c9b..0f7a200 100644 --- a/src/message/ske_messages.py +++ b/src/message/ske_messages.py @@ -58,7 +58,7 @@ 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.filterwords) + self.structure_name, self.structure_id = convert_structure(data.gramrel, data.lempos) self.other = {"score": data.score, "cm": data.cm} -- 2.36.5 From 54c536e68ca1a1370a98a8836a2d83dcf6b4ab20 Mon Sep 17 00:00:00 2001 From: LukeItUp Date: Thu, 23 Jul 2020 13:52:45 +0200 Subject: [PATCH 4/5] Fix for multiword examples --- .gitignore | 1 + src/message/ske_messages.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a67997d..4ad8b37 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,6 @@ build/* # using kdev4, works fairly nicely! .kdev4 **/*.kdev4 +remote diff --git a/src/message/ske_messages.py b/src/message/ske_messages.py index 0f7a200..5777f63 100644 --- a/src/message/ske_messages.py +++ b/src/message/ske_messages.py @@ -26,6 +26,7 @@ class SkeExample: self.mid = "" self.s_id = "" self.gf2_good = None + self.gf2_check = False @staticmethod def fromLine(line): @@ -140,7 +141,7 @@ class SkeModal(ClickMessage): elif type(data) is list: window.console.log(data) # check if gf2 examples are loaded or not - if data[0].gf2_good is None: + if not data[0].gf2_check: # 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) @@ -161,12 +162,18 @@ class SkeModalGf2Update(SkeModal): example.gf_good = False 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"]) for gf_sid, gf_data in good_response.items(): data_dict[gf_sid].left = gf_data.left data_dict[gf_sid].mid = gf_data.mid data_dict[gf_sid].right = gf_data.right data_dict[gf_sid].gf2_good = True + data_dict[gf_sid].gf2_check = True # changed data_dict, now we can redraw! # just let it do its thing in update_model @@ -216,6 +223,8 @@ class SkeInsert(DataChgClickMessage): else: console.log("You really should not be here, my lady") continue + + model.reset() def _as_corpus_example(self, example): new_example = Example() -- 2.36.5 From e1b302e2f52b40a708adad5ebb72e14d3ad5ae40 Mon Sep 17 00:00:00 2001 From: LukeItUp Date: Tue, 4 Aug 2020 08:52:31 +0200 Subject: [PATCH 5/5] Fix infinite collocation call loop --- src/message/ske_messages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/message/ske_messages.py b/src/message/ske_messages.py index 5777f63..301b37f 100644 --- a/src/message/ske_messages.py +++ b/src/message/ske_messages.py @@ -141,7 +141,7 @@ class SkeModal(ClickMessage): elif type(data) is list: window.console.log(data) # check if gf2 examples are loaded or not - if not data[0].gf2_check: + 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) -- 2.36.5