wooorm / franc

Natural language detection
https://wooorm.com/franc/
MIT License
4.07k stars 175 forks source link

I got NaN when runinng franc.all #29

Closed moshest closed 8 years ago

moshest commented 8 years ago

I run the following code:

franc.all('פאר טסי', {minLength: 3})
// result: [ [ 'heb', NaN ], [ 'ydd', NaN ] ]

Why I got NaN? Any quick fix?

wooorm commented 8 years ago

Quick fix would be to treat NaN as 0.

moshest commented 8 years ago

I did this hack:

franc.all(tran, FRANC_OPTIONS).forEach(function (item, i) {
  // FIXME remove this hack
  if (isNaN(item[1])) item[1] = 0.01 / i;
});
wooorm commented 8 years ago

Published as 1.1.3!

moshest commented 8 years ago

Saw your fix. Thanks.

In this case, "heb" is better suggestion over "ydd" and it's reasonable to suggest "heb" over "ydd". I think it's wrong to give both of them the same result. Am I right?

wooorm commented 8 years ago

From your human view, and familiarity with both languages, it is, but from franc’s, a humble machine, it is not. See GH-8, GH-16, GH-23, GH-27.

moshest commented 8 years ago

OK. Thanks!