Download
User Rating: 0/5 ( 0 votes)
Franc is a library to detect the language of text.
What’s so cool about franc?
-
franc supports more languages(†) than any other library, or Google;
-
franc is easily forked to support 300+ languages;
-
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.
Source: github.com
1. INCLUDE JS FILE
<script src="lib/franc.js"></script>
2. JAVASCRIPT
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 ],
* ...
* ]
*/
franc.all(''); // [ [ 'und', 1 ] ]
Note: franc returns the "und" language code for an undetermined language. This happens when the input value is too short to give a significant answer.