Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Typo and increased performance in analyze_sentence #2070

Merged
merged 2 commits into from
Jun 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions gensim/models/phrases.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ def analyze_sentence(self, sentence, threshold, common_terms, scorer):

"""
s = [utils.any2utf8(w) for w in sentence]
# adding None is a trick that helps getting an automatic happy ending
# as it won't be a common_word, nor score
s.append(None)
last_uncommon = None
in_between = []
# adding None is a trick that helps getting an automatic happy ending
# has it won't be a common_word, nor score
for word in s + [None]:
for word in s:
is_common = word in common_terms
if not is_common and last_uncommon:
chain = [last_uncommon] + in_between + [word]
Expand Down