jekyll / classifier-reborn

A general classifier module to allow Bayesian and other types of classifications. A fork of cardmagic/classifier.
https://jekyll.github.io/classifier-reborn/
GNU Lesser General Public License v2.1
548 stars 109 forks source link

Fix the corner cases #173

Closed sueka closed 6 years ago

sueka commented 6 years ago

I've tried doing

Ch4s3 commented 6 years ago

@sueka Thanks for the PR!

If you can fix NoMethodError: undefined methodzero?' for nil:NilClass`, I'll take a closer look.

sueka commented 6 years ago

@Ch4s3

Fixed it. I think there are two ways to fix the NoMethodError: the other is by using safe navigation operator to call zero? method.

Ch4s3 commented 6 years ago

This looks pretty good. Can you perhaps add a couple of test cases that would have previously caused zero division & zero vector normalization errors but are handled now?

I hate to keep throwing up barriers, but this is a tricky section of code, so I want to make sure we don't have a regression here.

Ch4s3 commented 6 years ago

Again @sueka thanks a ton. Once we get this in I'll roll out a new gem version. I'll try to get this into 2.2.1 with #174 if you can get to this soon, otherwise I'll roll it into2.3 with #162.

sueka commented 6 years ago

I've added tests against zero vector normalization and zero division errors.

Ch4s3 commented 6 years ago

Awesome, thanks again for the great contribution!