npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

languages.io

v0.9.1

Published

Multi Languages Detection for Text-Mining and Natural Language Processing - True ITK - Open Source

Downloads

3,012

Readme

Node.js languages.io

NPM version NPM downloads NPM license

Multi 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 = require('languages.io')
const language = new Languages()

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 = new Languages()

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.log(language.recognize(source))
/* {
    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 = new Languages()

var languageCode = 'en' /* ( "English"  | "English" | "en"  | "eng" | "eng" | "eng" | "eng" ) */
var isoCode = 1         /* ( "name"     | "local"   | 1     | 2     | 3     | "2T"  | "2B"  ) */

console.log(language.isLanguageCode(languageCode, isoCode)) /* => boolean (true / false) check if "en" = ISO 639 Language Code  */

if (language.isLanguageCode(languageCode, isoCode)) /* => 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 = new Languages()

var languageCode = 'en' /* ( "English"  | "English" | "en"  | "eng" | "eng" | "eng" | "eng" ) */
var isoCode = 1         /* ( "name"     | "local"   | 1     | 2     | 3     | "2T"  | "2B"  ) */

console.log(language.getLanguageCodes(languageCode, isoCode))
/* {
    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 = new Languages()

var source = 'Returns true or false if the source matches the language.'

console.log(language.isGerman(source))        /* => boolean (true / false) check if source = German  */
console.log(language.isEnglish(source))       /* => boolean (true / false) check if source = English  */
console.log(language.isFrench(source))        /* => boolean (true / false) check if source = French  */
console.log(language.isSpanish(source))       /* => boolean (true / false) check if source = Spanish  */
console.log(language.isItalian(source))       /* => boolean (true / false) check if source = Italian  */
console.log(language.isDutch(source))         /* => boolean (true / false) check if source = Dutch  */
console.log(language.isPolish(source))        /* => boolean (true / false) check if source = Polish  */
console.log(language.isFinnish(source))       /* => boolean (true / false) check if source = Finnish  */
console.log(language.isFarsi(source))         /* => boolean (true / false) check if source = Farsi  */
console.log(language.isRussian(source))       /* => boolean (true / false) check if source = Russian  */
console.log(language.isPortugese(source))     /* => boolean (true / false) check if source = Portugese  */
console.log(language.isNorwegian(source))     /* => boolean (true / false) check if source = Norwegian  */
console.log(language.isSwedish(source))       /* => boolean (true / false) check if source = Swedish  */
console.log(language.isVietnamese(source))    /* => boolean (true / false) check if source = Vietnamese  */
console.log(language.isJapanese(source))      /* => boolean (true / false) check if source = Japanese  */

if (language.isEnglish(source)) /* => true */
if (!language.isGerman(source)) /* => true */

License

This project is licensed under the GNU GPLv3 License - see the LICENSE file for details © John Ollhorn [email protected]