wooorm / franc

Natural language detection

Home Page:https://wooorm.com/franc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

the official example of `only` not working

Megrax opened this issue · comments

console.log(franc.all('O Brasil caiu 26 posições', {only: ['por', 'spa']}))

It is expected to output [ [ 'por', 1 ], [ 'spa', 0.799906059182715 ] ] .
BUT what I've got is

[
  [ 'por', 1 ],
  [ 'src', 0.8797557538750587 ],
  [ 'glg', 0.8708313762329732 ],
  [ 'snn', 0.8633161108501644 ],
  [ 'bos', 0.8172851103804604 ],
  [ 'hrv', 0.8107092531705026 ],
  [ 'lav', 0.8088304368248004 ],
  [ 'cat', 0.8069516204790982 ],
  [ 'spa', 0.799906059182715 ],
  [ 'bam', 0.799906059182715 ],
  [ 'sco', 0.7806481916392672 ],
  [ 'rup', 0.7538750587130107 ],
  [ 'rmy', 0.7538750587130107 ],
  [ 'srp', 0.7524659464537342 ],
  [ 'bcl', 0.7407233442930954 ],
  [ 'rmn', 0.7393142320338186 ],
  [ 'ita', 0.7355565993424142 ],
  [ 'vec', 0.7111319868482856 ],
  [ 'slk', 0.7078440582433068 ],
  [ 'tpi', 0.6890558947862846 ],
  [ 'min', 0.6843588539220291 ],
  [ 'pol', 0.6829497416627525 ],
  [ 'epo', 0.6801315171441992 ],
  [ 'dan', 0.674025364020667 ],
  [ 'fra', 0.6721465476749648 ],
  [ 'ron', 0.6660403945514326 ],
  [ 'ces', 0.6632221700328793 ],
  [ 'nob', 0.651949271958666 ],
  [ 'sot', 0.6486613433536872 ],
  [ 'nso', 0.646782527007985 ],
  [ 'sna', 0.6453734147487082 ],
  [ 'tsn', 0.6416157820573039 ],
  [ 'lin', 0.6406763738844528 ],
  [ 'run', 0.6378581493658995 ],
  [ 'hms', 0.6326914044152184 ],
  [ 'slv', 0.6326914044152184 ],
  [ 'hat', 0.6312822921559418 ],
  [ 'sun', 0.6261155472052606 ],
  [ 'ckb', 0.6256458431188352 ],
  [ 'bem', 0.620479098168154 ],
  [ 'azj', 0.6176608736496008 ],
  [ 'umb', 0.6092062000939409 ],
  [ 'afr', 0.6073273837482387 ],
  [ 'bug', 0.5941756693283231 ],
  [ 'tem', 0.5904180366369187 ],
  [ 'uzn', 0.5894786284640676 ],
  [ 'als', 0.588069516204791 ],
  [ 'kmb', 0.5852512916862377 ],
  [ 'jav', 0.5824330671676843 ],
  [ 'war', 0.575387505871301 ],
  [ 'est', 0.5706904650070456 ],
  [ 'swh', 0.5622357914513856 ],
  [ 'nno', 0.5622357914513856 ],
  [ 'bin', 0.5603569751056834 ],
  [ 'ayr', 0.559887271019258 ],
  [ 'lit', 0.5589478628464067 ],
  [ 'zyb', 0.5575387505871301 ],
  [ 'vie', 0.556599342414279 ],
  [ 'fuv', 0.5556599342414279 ],
  [ 'ban', 0.5547205260685768 ],
  [ 'nya', 0.5537811178957257 ],
  [ 'ewe', 0.5509628933771724 ],
  [ 'mad', 0.5481446688586191 ],
  [ 'tzm', 0.5467355565993424 ],
  [ 'pam', 0.5457961484264913 ],
  [ 'cjk', 0.5392202912165336 ],
  [ 'deu', 0.538750587130108 ],
  [ 'kin', 0.5373414748708314 ],
  [ 'eng', 0.5307656176608737 ],
  [ 'emk', 0.5279473931423204 ],
  [ 'ceb', 0.5270079849694692 ],
  [ 'aka', 0.5241897604509159 ],
  [ 'hun', 0.5209018318459371 ],
  [ 'toi', 0.5194927195866603 ],
  [ 'tgl', 0.5171441991545327 ],
  [ 'hnj', 0.516674495068107 ],
  [ 'kng', 0.5147956787224048 ],
  [ 'bci', 0.5143259746359794 ],
  [ 'suk', 0.5138562705495537 ],
  [ 'ind', 0.5133865664631283 ],
  [ 'quz', 0.5124471582902772 ],
  [ 'som', 0.5091592296852983 ],
  [ 'hil', 0.5054015969938939 ],
  [ 'uig', 0.5049318929074683 ],
  [ 'ibo', 0.5044621888210428 ],
  [ 'nhn', 0.503053076561766 ],
  [ 'yao', 0.5011742602160638 ],
  [ 'ndo', 0.497886331611085 ],
  [ 'zlm', 0.4960075152653828 ],
  [ 'nyn', 0.4922498825739784 ],
  [ 'ace', 0.4903710662282762 ],
  [ 'fon', 0.48990136214185065 ],
  [ 'ada', 0.480037576326914 ],
  [ 'quy', 0.47862846406763737 ],
  [ 'ilo', 0.47440112728980743 ],
  [ 'tso', 0.4692343823391264 ],
  [ 'snk', 0.46688586190699854 ],
  [ 'fin', 0.46500704556129635 ],
  [ 'lug', 0.4645373414748708 ],
  [ 'swe', 0.4635979333020197 ],
  ... 29 more items
]

Why would this happen? What I did is simply following the official guide in README.

commented

Can’t reproduce: https://runkit.com/embed/e1ddrps0knds.
You might have an outdated version of franc, or something else weird going on locally