8000 GitHub - godeep/franc: Detect the language of text
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

godeep/franc

 
 

Repository files navigation

franc

Build Status Coverage Status Code Climate

Detect the language of text.

What’s so cool about franc?

  1. franc supports more languages(†) than any other library, or Google;
  2. franc is easily forked to support 300+ languages;
  3. franc is just as fast as the competition.

† - If humans write in the language, on the web, and the language has more than one million speakers, franc detects it.

Installation

npm:

$ npm install franc

Component:

$ component install wooorm/franc

Bower:

$ bower install franc

Usage

var franc = require('franc');

franc('Alle menslike wesens word vry'); // "afr"
franc('এটি একটি ভাষা একক IBM স্ক্রিপ্ট'); // "ben"
franc('Alle mennesker er født frie og'); // "nno"
franc(''); // "und"

franc.all('O Brasil caiu 26 posições em');
/*
 * [
 *   [ 'por', 5507 ],
 *   [ 'glg', 6270 ],
 *   [ 'src', 6292 ],
 *   [ 'lav', 6391 ],
 *   [ 'cat', 6432 ],
 *   [ 'spa', 6481 ],
 *   [ 'bos', 6509 ],
 *   [ 'tpi', 6526 ],
 *   [ 'hrv', 6532 ],
 *   [ 'snn', 6556 ],
 *   [ 'bam', 6693 ],
 *   [ 'sco', 6695 ],
 *   ...
 * ]
 */

/* "und" is returned for too-short input: */
franc.all(''); // [ [ 'und', 1 ] ]

/* Provide a whitelist: */
franc.all('O Brasil caiu 26 posições em', {
    'whitelist' : ['por', 'src', 'glg', 'spa']
});
/*
 * [
 *   [ 'por', 5507 ],
 *   [ 'glg', 6270 ],
 *   [ 'src', 6292 ],
 *   [ 'spa', 6481 ]
 * ]
*/

/* Provide a blacklist: */
franc.all('O Brasil caiu 26 posições em', {
    'blacklist' : ['src', 'glg', 'lav']
});
/*
 * [
 *   [ 'por', 5507 ],
 *   [ 'cat', 6432 ],
 *   [ 'spa', 6481 ],
 *   [ 'bos', 6509 ],
 *   [ 'tpi', 6526 ],
 *   [ 'hrv', 6532 ],
 *   [ 'snn', 6556 ],
 *   [ 'bam', 6693 ],
 *   [ 'sco', 6695 ],
 *   ...
 * ]
 */

Supported languages

franc supports 175 “languages”. For a complete list, check out Supported-Languages.md.

Benchmark

On a MacBook Air, it runs 175 paragraphs 2 times per second (total: 350 op/s).

         benchmarks * 175 paragraphs in different languages
  2 op/s » franc -- this module
  2 op/s » guesslanguage
  2 op/s » languagedetect
  2 op/s » vac

(I’ll work on a better benchmark soon)

License

LGPL © Titus Wormer

About

Detect the language of text

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0