Skip to content

Release v1.0#60

Open
harisalam wants to merge 26 commits intomasterfrom
release-v1.0
Open

Release v1.0#60
harisalam wants to merge 26 commits intomasterfrom
release-v1.0

Conversation

@harisalam
Copy link
Copy Markdown
Contributor

This is the release version of the project! I'm creating the pull request for code reviews and helpful comments.

Comment thread src/app.py
"sel_result": sel_result_kwic})


@app.route('/find2', methods=['POST'])
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/service.py
# 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(" "))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can merge these two functions in a single function which I uploaded in my last pull request for more efficiency.

Comment thread src/util.py
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*' '
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can color the selected word in order to stand out among the sentence.

Comment thread src/service.py Outdated
remember: sel_word is lemmatized
"""
if length <= 0:
if length <= 0 or len(words_of_sentence) <= length:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants