wooorm / franc

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

"only" parameter returns always score = 1 #96

Closed dbuchet closed 3 years ago

dbuchet commented 3 years ago

Using parameter only with franc.all returns all languages defined with score = 1

franc.all('This is a text written in English')); // => Expected result with ['fra', 0.5710206995003568] in array
franc.all('This is a text written in English', {only: ['fra']}); // => ['fra', 1]

https://stackblitz.com/edit/react-esuzot?file=src/App.js

Thanks :)

wooorm commented 3 years ago

What do you expect to happen? By saying the result can only be French, well, the result wil be 100% French.

dbuchet commented 3 years ago

Oh make sense when you explained it like this, but I was expected ['fra', 0.5710206995003568] In fact using only I was thinking I will only have the scoring for the provided languages.

So yes, basically, it's just an integrated filter (so my expectation is quite easy to implement on my side) Thanks for your answer!

wooorm commented 3 years ago

:+1:

This might touch upon https://github.com/wooorm/franc/issues/89.

But otherwise, I think the current output makes sense!