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

Did a lot of refactoring... #2

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Conversation

maymount
Copy link

@maymount maymount commented Nov 3, 2014

I did so much refactoring that you might not want to accept the changes.

However, I did find a bug that you should definitely fix.

Line 204: good_metric = [ 1.0, other_count / pool_count ].min
Line 209: bad_metric = [ 1.0, this_count / them_count ].min

Ruby is treating those divisions as integers, and since the numerator is less than the denominator the result is always 0. The effect is that tokens always have a probability of 0.999 instead of a lower probability for tokens that appear in multiple pools.

The fix is to force the values to be floats:

good_metric = [ 1.0, Float(other_count) / Float(pool.token_count) ].min

Other than that:

  1. Lots of refactoring, encapsulating logic, making things private, and removing vestigial code.
  2. Corpus is generated just like the cache, and treated separately, which simplified a lot of code
  3. Tests
  4. RDoc comments

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.

1 participant