From d01f5fdb12c9d16eaccf7ad1390dbb4e52d3f069 Mon Sep 17 00:00:00 2001 From: Kirill Malakhov Date: Tue, 10 Dec 2019 14:13:39 +0200 Subject: [PATCH 1/4] Fixed spelling Fixed spelling --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a85e9e3..1f400bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### 🔴 Виправлення помилок -- Виправленол помилку при нумерації речень в `allterms.xml`. Нумерація речень в `allterms.xml` починається з `0`. +- Виправлено помилку при нумерації речень в `allterms.xml`. Нумерація речень в `allterms.xml` починається з `0`. Для індексації речень з використанням `spaCy` (в цій бібліотеці відсутня індексація речень) за основу використано [приклад](https://stackoverflow.com/questions/58197863/how-to-get-sentence-number-in-spacy): ```python for sent_i, sent in enumerate(doc.sents): @@ -19,7 +19,6 @@ Конспект (EN) - v1.0.4 ``` - ## v1.0.3, 2019-10-31 ### ⚠️ Зауваження From 6cb96032f81ffc0a45d49d02f925ab96fcf18121 Mon Sep 17 00:00:00 2001 From: Kirill Malakhov Date: Wed, 11 Dec 2019 11:11:41 +0200 Subject: [PATCH 2/4] Fixed index in `` / `` tags Fixed index in `` / `` tags allterms.xml`. Index in the `` / `` tags of the `allterms.xml` begins with` 0`. --- ken.py | 52 ++++++++++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/ken.py b/ken.py index 68e5548..1be52fa 100644 --- a/ken.py +++ b/ken.py @@ -695,12 +695,10 @@ def get_terms_list(): # already exists in one_word_terms_help_list if chunk.root.lemma_ in one_word_terms_help_list: - relup_index = 0 - reldown_index = 0 sent_pos_helper = [] - for one_term in exporterms_element.findall('term'): - relup_index+=1 + for relup_index, one_term in enumerate(exporterms_element.findall('term')): + if one_term.find('tname').text == chunk.root.lemma_: for sent_pos in one_term.findall('sentpos'): @@ -727,16 +725,14 @@ def get_terms_list(): if t.pos_ in ['NOUN']: if t.lemma_ in one_word_terms_help_list: - relup_index = 0 - reldown_index = 0 sent_pos_helper = [] if t.i == 0: index_helper = chunk.start+1 else: index_helper = chunk.start+2 - for one_term in exporterms_element.findall('term'): - relup_index+=1 + for relup_index, one_term in enumerate(exporterms_element.findall('term')): + if one_term.find('tname').text == t.lemma_: for sent_pos in one_term.findall('sentpos'): @@ -792,12 +788,10 @@ def get_terms_list(): # add relup/reldown if chunk.root.lemma_ in one_word_terms_help_list: - relup_index = 0 - reldown_index = 0 sent_pos_helper = [] - for one_term in exporterms_element.findall('term'): - relup_index+=1 + for relup_index, one_term in enumerate(exporterms_element.findall('term')): + if one_term.find('tname').text == chunk.root.lemma_: for sent_pos in one_term.findall('sentpos'): @@ -814,8 +808,8 @@ def get_terms_list(): new_sentpos_element.text = str(sentence_index) + '/' + str(chunk.start+2) one_term.append(new_sentpos_element) - for two_term in exporterms_element.findall('term'): - reldown_index+=1 + for reldown_index, two_term in enumerate(exporterms_element.findall('term')): + # if two_term.find('tname').text == chunk.lower_: if two_term.find('tname').text == chunk.lemma_: new_relup_element = ET.Element('relup') @@ -864,13 +858,11 @@ def get_terms_list(): # append to exporterms_element.append(new_term_element) - relup_index = 0 - reldown_index = 0 - for one_term in exporterms_element.findall('term'): - relup_index+=1 + for relup_index, one_term in enumerate(exporterms_element.findall('term')): + if one_term.find('tname').text == chunk.root.lemma_: - for two_term in exporterms_element.findall('term'): - reldown_index+=1 + for reldown_index, two_term in enumerate(exporterms_element.findall('term')): + # if two_term.find('tname').text == chunk.lower_: if two_term.find('tname').text == chunk.lemma_: new_relup_element = ET.Element('relup') @@ -888,8 +880,6 @@ def get_terms_list(): if t.lemma_ in one_word_terms_help_list: - relup_index = 0 - reldown_index = 0 sent_pos_helper = [] if t.i == 0: index_helper = chunk.start+1 @@ -897,11 +887,11 @@ def get_terms_list(): index_helper = chunk.start+2 - for one_term in exporterms_element.findall('term'): - relup_index+=1 + for relup_index, one_term in enumerate(exporterms_element.findall('term')): + if one_term.find('tname').text == t.lemma_: - for two_term in exporterms_element.findall('term'): - reldown_index+=1 + for reldown_index, two_term in enumerate(exporterms_element.findall('term')): + # if two_term.find('tname').text == chunk.lower_: if two_term.find('tname').text == chunk.lemma_: @@ -924,8 +914,6 @@ def get_terms_list(): # print('if t.lemma_ not in one_word_terms_help_list ----->>>>>>' + t.lemma_) - relup_index = 0 - reldown_index = 0 sent_pos_helper = [] if t.i == 0: @@ -961,11 +949,11 @@ def get_terms_list(): # append to exporterms_element.append(new_term_element) - for one_term in exporterms_element.findall('term'): - relup_index+=1 + for relup_index, one_term in enumerate(exporterms_element.findall('term')): + if one_term.find('tname').text == t.lemma_: - for two_term in exporterms_element.findall('term'): - reldown_index+=1 + for reldown_index, two_term in enumerate(exporterms_element.findall('term')): + # if two_term.find('tname').text == chunk.lower_: if two_term.find('tname').text == chunk.lemma_: From 9e892a56def73d169ee35ba06b9caea2707f1fa2 Mon Sep 17 00:00:00 2001 From: Kirill Malakhov Date: Wed, 11 Dec 2019 11:13:05 +0200 Subject: [PATCH 3/4] Fixed `JavaScript` according to new index Fixed `JavaScript` on the client-side according to new index in tags` `/` `,` `of file ` allterms.xml`. --- static/javascripts/ken-recap.js | 44 ++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/static/javascripts/ken-recap.js b/static/javascripts/ken-recap.js index d55d4ea..531b679 100644 --- a/static/javascripts/ken-recap.js +++ b/static/javascripts/ken-recap.js @@ -904,10 +904,10 @@ function forUploadResultListClickAndEnterPressEvents() { let sentIndex = []; let sentsForMark = []; for (let elementForUploadResultListDbClickAndEnterPress of alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].sentpos) { - if (!sentIndex.includes(parseInt(elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")) - 1))) { - $textContent.append('

' + alltermsJSON.termsintext.sentences.sent[elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")) - 1] + '


'); - sentsForMark.push(alltermsJSON.termsintext.sentences.sent[elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")) - 1]); - sentIndex.push(parseInt(elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")) - 1)); + if (!sentIndex.includes(parseInt(elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/"))))) { + $textContent.append('

' + alltermsJSON.termsintext.sentences.sent[elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/"))] + '


'); + sentsForMark.push(alltermsJSON.termsintext.sentences.sent[elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/"))]); + sentIndex.push(parseInt(elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")))); } } mark(sentsForMark); @@ -915,9 +915,9 @@ function forUploadResultListClickAndEnterPressEvents() { if (Array.isArray(alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].sentpos) == false) { - $textContent.append('

' + alltermsJSON.termsintext.sentences.sent[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].sentpos.substring(0, alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].sentpos.indexOf("/")) - 1] + '


'); + $textContent.append('

' + alltermsJSON.termsintext.sentences.sent[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].sentpos.substring(0, alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].sentpos.indexOf("/"))] + '


'); - mark(alltermsJSON.termsintext.sentences.sent[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].sentpos.substring(0, alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].sentpos.indexOf("/")) - 1]); + mark(alltermsJSON.termsintext.sentences.sent[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].sentpos.substring(0, alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].sentpos.indexOf("/"))]); } // inserting terms in tree #term-tree @@ -929,11 +929,11 @@ function forUploadResultListClickAndEnterPressEvents() { // add child nodes to template structure for bootstrap-treeview if (Array.isArray(alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].reldown)) { for (let elementForTermTree of alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].reldown) { - objForTree.nodes[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].reldown.indexOf(elementForTermTree)] = { text: alltermsJSON.termsintext.exporterms.term[elementForTermTree - 1].tname }; + objForTree.nodes[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].reldown.indexOf(elementForTermTree)] = { text: alltermsJSON.termsintext.exporterms.term[elementForTermTree].tname }; } } if (Array.isArray(alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].reldown) == false) { - objForTree.nodes[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].reldown.indexOf(alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].reldown)] = { text: alltermsJSON.termsintext.exporterms.term[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].reldown - 1].tname }; + objForTree.nodes[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].reldown.indexOf(alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].reldown)] = { text: alltermsJSON.termsintext.exporterms.term[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].reldown].tname }; } treeData.length = 0; //clear treeData array @@ -949,18 +949,18 @@ function forUploadResultListClickAndEnterPressEvents() { let selectedTermInTermTree = termsWithIndexDict[node.text]; if (Array.isArray(alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos) == false) { - $textContent.append('

' + alltermsJSON.termsintext.sentences.sent[alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.substring(0, alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.indexOf("/")) - 1] + '


'); + $textContent.append('

' + alltermsJSON.termsintext.sentences.sent[alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.substring(0, alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.indexOf("/"))] + '


'); - mark(alltermsJSON.termsintext.sentences.sent[alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.substring(0, alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.indexOf("/")) - 1]); + mark(alltermsJSON.termsintext.sentences.sent[alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.substring(0, alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.indexOf("/"))]); } if (Array.isArray(alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos)) { let sentIndex = []; let sentsForMark = []; for (let elementForUploadResultListDbClickAndEnterPress of alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos) { - if (!sentIndex.includes(parseInt(elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")) - 1))) { - $textContent.append('

' + alltermsJSON.termsintext.sentences.sent[elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")) - 1] + '


'); - sentsForMark.push(alltermsJSON.termsintext.sentences.sent[elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")) - 1]); - sentIndex.push(parseInt(elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")) - 1)); + if (!sentIndex.includes(parseInt(elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/"))))) { + $textContent.append('

' + alltermsJSON.termsintext.sentences.sent[elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/"))] + '


'); + sentsForMark.push(alltermsJSON.termsintext.sentences.sent[elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/"))]); + sentIndex.push(parseInt(elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")))); } } mark(sentsForMark); @@ -984,11 +984,11 @@ function forUploadResultListClickAndEnterPressEvents() { // add child nodes to template structure for bootstrap-treeview if (Array.isArray(alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].relup)) { for (let elementForTermTree of alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].relup) { - objForTree.nodes[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].relup.indexOf(elementForTermTree)] = { text: alltermsJSON.termsintext.exporterms.term[elementForTermTree - 1].tname }; + objForTree.nodes[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].relup.indexOf(elementForTermTree)] = { text: alltermsJSON.termsintext.exporterms.term[elementForTermTree].tname }; } } if (Array.isArray(alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].relup) == false) { - objForTree.nodes[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].relup.indexOf(alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].relup)] = { text: alltermsJSON.termsintext.exporterms.term[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].relup - 1].tname }; + objForTree.nodes[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].relup.indexOf(alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].relup)] = { text: alltermsJSON.termsintext.exporterms.term[alltermsJSON.termsintext.exporterms.term[valOfSelectedElementInUploadResultList].relup].tname }; } treeData.length = 0; //clear treeData array @@ -1005,18 +1005,18 @@ function forUploadResultListClickAndEnterPressEvents() { let selectedTermInTermTree = termsWithIndexDict[node.text]; if (Array.isArray(alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos) == false) { - $textContent.append('

' + alltermsJSON.termsintext.sentences.sent[alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.substring(0, alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.indexOf("/")) - 1] + '


'); + $textContent.append('

' + alltermsJSON.termsintext.sentences.sent[alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.substring(0, alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.indexOf("/"))] + '


'); - mark(alltermsJSON.termsintext.sentences.sent[alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.substring(0, alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.indexOf("/")) - 1]); + mark(alltermsJSON.termsintext.sentences.sent[alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.substring(0, alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos.indexOf("/"))]); } if (Array.isArray(alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos)) { let sentIndex = []; let sentsForMark = []; for (let elementForUploadResultListDbClickAndEnterPress of alltermsJSON.termsintext.exporterms.term[selectedTermInTermTree].sentpos) { - if (!sentIndex.includes(parseInt(elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")) - 1))) { - $textContent.append('

' + alltermsJSON.termsintext.sentences.sent[elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")) - 1] + '


'); - sentsForMark.push(alltermsJSON.termsintext.sentences.sent[elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")) - 1]); - sentIndex.push(parseInt(elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")) - 1)); + if (!sentIndex.includes(parseInt(elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/"))))) { + $textContent.append('

' + alltermsJSON.termsintext.sentences.sent[elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/"))] + '


'); + sentsForMark.push(alltermsJSON.termsintext.sentences.sent[elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/"))]); + sentIndex.push(parseInt(elementForUploadResultListDbClickAndEnterPress.substring(0, elementForUploadResultListDbClickAndEnterPress.indexOf("/")))); } } mark(sentsForMark); From d996f9b220d4c97adb72e99819019518d0480559 Mon Sep 17 00:00:00 2001 From: Kirill Malakhov Date: Wed, 11 Dec 2019 11:13:29 +0200 Subject: [PATCH 4/4] Update to v1.0.5 Update to v1.0.5 --- CHANGELOG.md | 9 ++++++++- templates/index.html | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f400bc..8cb22e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,15 @@ +## v1.0.5, 2019-12-11 + +### 🔴 Виправлення помилок +- Виправлено помилку при нумерації в тегах ``/`` файлу `allterms.xml`. + Нумерація в тегах ``/`` файлу `allterms.xml` починається з `0`. +- Виправлення `JavaScript` на клієнті згідно нової нумерації в тегах ``/``, `` файлу `allterms.xml`. + ## v1.0.4, 2019-12-10 ### 🔴 Виправлення помилок -- Виправлено помилку при нумерації речень в `allterms.xml`. Нумерація речень в `allterms.xml` починається з `0`. +- Виправлено помилку при нумерації речень в тегу `` файлу `allterms.xml`. Нумерація речень в тегу `` файлу `allterms.xml` починається з `0`. Для індексації речень з використанням `spaCy` (в цій бібліотеці відсутня індексація речень) за основу використано [приклад](https://stackoverflow.com/questions/58197863/how-to-get-sentence-number-in-spacy): ```python for sent_i, sent in enumerate(doc.sents): diff --git a/templates/index.html b/templates/index.html index 36534ed..f5f8bc6 100644 --- a/templates/index.html +++ b/templates/index.html @@ -2,7 +2,7 @@ - Конспект (EN) - v1.0.4 + Конспект (EN) - v1.0.5