Conversation
| "sel_result": sel_result_kwic}) | ||
|
|
||
|
|
||
| @app.route('/find2', methods=['POST']) |
There was a problem hiding this comment.
This code inside this function is the same as the function above. How about if we can make it generic and make it work using a single function.
| # Highlight Keywords | ||
| # result_text = find_and_replace(result_text, selword, "\x1b[34m" + selword + "\x1b[0m") | ||
| # sents_kwic.append(result_text) | ||
| window_words = get_keyword_window(selword, sent.split(" ")) |
There was a problem hiding this comment.
we can merge these two functions in a single function which I uploaded in my last pull request for more efficiency.
| key_index = sent.lower().index(sel_word.lower()) | ||
| if key_index != -1: | ||
| pre_kwic = sent[:key_index].rjust(sum_sent_length//2) | ||
| key_kwic = key_word_space*' ' + sel_word + key_word_space*' ' |
There was a problem hiding this comment.
We can color the selected word in order to stand out among the sentence.
| remember: sel_word is lemmatized | ||
| """ | ||
| if length <= 0: | ||
| if length <= 0 or len(words_of_sentence) <= length: |
There was a problem hiding this comment.
Rather than finding the length of the sentence manually, the following code will divide the sentence into 5 words based on the selected word:
ngrams = [wordlist[i:i + 5] for i in range(len(wordlist) - 4)].
Dividing the sentence into chunks of 5 words including the selected word as central point.
This is the release version of the project! I'm creating the pull request for code reviews and helpful comments.