languages.io
Node.jsMulti Languages Detection for Text-Mining and Natural Language Processing
Built With
- franc-all - Detect the language of text.
- langs - This library provides ISO 639-1/2/3 language codes with English and local names.
- node-nlp - "NLP.js" is a general natural language utilities for nodejs.
Installing
$ npm install --save languages.io
Usage
const Languages = const language =
Recognizes the language of a text
Detects the language of the given string and returns an object with all available ISO 639 language codes along with the accuracy. The accuracy should be as close as possible to "1", which is the best result, an accuracy below 1 should be followed by further testing. The text passed should be as long as possible so that the accuracy is as high as possible.
const language = var source = 'Erkennt die Sprache der übergebenen Zeichenkette und gibt ein Objekt mit allen verfügbaren ISO 639 Sprach Codes zusammen mit der Genauigkeit zurück. Die Genauigkeit sollte möglichst bei "1" liegen, was dem besten Ergebniss entspricht, einer Genauigkeit von unter 1 sollten weiteren Test folgen. Der übergebene Text sollte möglichst lang sein damit die Genauigkeit möglichst hoch ist.' console/* { name: 'German', local: 'Deutsch', code: 'DE', accuracy: 1, ISO639_1: 'de', ISO639_2: 'deu', ISO639_3: 'deu', ISO639_2T: 'deu', ISO639_2B: 'ger'} */
A list of all available languages including their speakers. (It should meet all common requirements 😁)
Check ISO 639 language code
Check if the passed string is a language code according to ISO 639
const language = var languageCode = 'en' /* ( "English" | "English" | "en" | "eng" | "eng" | "eng" | "eng" ) */var isoCode = 1 /* ( "name" | "local" | 1 | 2 | 3 | "2T" | "2B" ) */ console /* => boolean (true / false) check if "en" = ISO 639 Language Code */ if language /* => true */
Returns Object with ISO 639 Codes
Returns an object with all recognized ISO 639 codes based on a single passed ISO code.
const language = var languageCode = 'en' /* ( "English" | "English" | "en" | "eng" | "eng" | "eng" | "eng" ) */var isoCode = 1 /* ( "name" | "local" | 1 | 2 | 3 | "2T" | "2B" ) */ console/* { name: 'English', local: 'English', code: 'EN', ISO639_1: 'en', ISO639_2: 'eng', ISO639_3: 'eng', ISO639_2T: 'eng', ISO639_2B: 'eng'} */
Check certain language
Check if a string corresponds to a certain language
const language = var source = 'Returns true or false if the source matches the language.' console /* => boolean (true / false) check if source = German */console /* => boolean (true / false) check if source = English */console /* => boolean (true / false) check if source = French */console /* => boolean (true / false) check if source = Spanish */console /* => boolean (true / false) check if source = Italian */console /* => boolean (true / false) check if source = Dutch */console /* => boolean (true / false) check if source = Polish */console /* => boolean (true / false) check if source = Finnish */console /* => boolean (true / false) check if source = Farsi */console /* => boolean (true / false) check if source = Russian */console /* => boolean (true / false) check if source = Portugese */console /* => boolean (true / false) check if source = Norwegian */console /* => boolean (true / false) check if source = Swedish */console /* => boolean (true / false) check if source = Vietnamese */console /* => boolean (true / false) check if source = Japanese */ if language /* => true */if !language /* => true */
License
This project is licensed under the GNU GPLv3 License - see the LICENSE file for details © John Ollhorn john.ollhorn@true-itk.de