Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Viterbi Calculation Reusability + Comment Fixes #429

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

Closed
wants to merge 1 commit into from
Closed

Viterbi Calculation Reusability + Comment Fixes #429

wants to merge 1 commit into from

Conversation

antmarakis
Copy link
Collaborator

@antmarakis antmarakis commented Mar 28, 2017

In viterbi_segment, the calculation P[w] * best[i - len(w)] is used twice in a row, so I stored it into a variable (curr_score) and used that instead.

Also made quotation and spacing fixes to the comments.

for i in range(n+1):
for j in range(0, i):
w = text[j:i]
if P[w] * best[i - len(w)] >= best[i]:
best[i] = P[w] * best[i - len(w)]
curr_score = P[w] * best[i - len(w)]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have seen curr_something (or currSomething etc.) pop up a lot around, so I assume most people will get it. The problem with p_score is that p doesn't give enough information, which is not the same case as curr_score.

I personally feel it's fine, but I don't feel strongly about it. If more have the same issue, I will change it.

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right. I'm sure most won't have an issue.

@antmarakis
Copy link
Collaborator Author

Branch was deleted, will make a new PR.

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.

2 participants