• Stars
    star
    210
  • Rank 181,171 (Top 4 %)
  • Language
    JavaScript
  • Created over 11 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A natural language detection library based on trigram statistical analysis for Node.js and the Web.

guessLanguage.js

A natural language detection library based on trigram statistical analysis. This library is written in JavaScript and works equally well when run in either the Browser or Node.js.

Demo

An online demo is available here.

Usage

You can clone this repo as follows:

git clone [email protected]:richtr/guessLanguage.js.git

You can use this library in a web page by including the following files:

<script src="lib/_languageData.js"></script>
<script src="lib/guessLanguage.js"></script>

You can also use this library in a Node.js project. This library can be installed via npm as follows:

sudo npm install -g guesslanguage

Including this library for use in a Node.js project can then be done as follows:

var guessLanguage = require('./lib/guessLanguage');
// See the API section for usage

API

You can use guessLanguage.js in any of the following ways:

guessLanguage.detect('...input text here...', function(language) {
  console.log('Detected language code of provided text is [' + language + ']');
});
guessLanguage.name('...input text here...', function(languageName) {
  console.log('Detected language name of provided text is [' + languageName + ']');
});
guessLanguage.code('...input text here...', function(languageIANA) {
  console.log('Detected language IANA number of provided text is [' + languageIANA + ']');
});
guessLanguage.info('...input text here...', function(languageInfo) {
  console.log('Detected language code of provided text is [' + languageInfo[0] + ']');
  console.log('Detected language IANA number of provided text is [' + languageInfo[1] + ']');
  console.log('Detected language name of provided text is [' + languageInfo[2] + ']');
});

Languages Supported: 100

  • "ab": Abkhazian
  • "af": Afrikaans
  • "ar": Arabic
  • "az": Azerbaijani
  • "be": Belarusian
  • "bg": Bulgarian
  • "bn": Bengali
  • "bo": Tibetan
  • "br": Breton
  • "ca": Catalan, Valencian
  • "ceb": Cebuano
  • "cs": Czech
  • "cy": Welsh
  • "da": Danish
  • "de": German
  • "el": Modern Greek
  • "en": English
  • "eo": Esperanto
  • "es": Spanish, Castilian
  • "et": Estonian
  • "eu": Basque
  • "fa": Persian
  • "fi": Finnish
  • "fo": Faroese
  • "fr": French
  • "fy": Western Frisian
  • "gd": Scottish Gaelic, Gaelic
  • "gl": Galician
  • "gu": Gujarati
  • "ha": Hausa
  • "haw": Hawaiian
  • "he": Hebrew
  • "hi": Hindi
  • "hr": Croatian
  • "hu": Hungarian
  • "hy": Armenian
  • "id": Indonesian
  • "is": Icelandic
  • "it": Italian
  • "ja": Japanese
  • "ka": Georgian
  • "kk": Kazakh
  • "km": Central Khmer
  • "kn": Kannada
  • "ko": Korean
  • "ku": Kurdish
  • "ky": Kirghiz, Kyrgyz
  • "la": Latin
  • "lo": Lao
  • "lt": Lithuanian
  • "lv": Latvian
  • "mg": Malagasy
  • "mk": Macedonian
  • "ml": Malayalam
  • "mn": Mongolian
  • "mr": Marathi
  • "ms": Malay (macrolanguage)
  • "nd": North Ndebele
  • "ne": Nepali
  • "nl": Dutch, Flemish
  • "nn": Norwegian Nynorsk
  • "no": Norwegian
  • "nso": Pedi, Northern Sotho, Sepedi
  • "or": Oriya
  • "pa": Panjabi, Punjabi
  • "pl": Polish
  • "ps": Pushto, Pashto
  • "pt": Portuguese
  • "pt-BR": Portuguese (Brazil)
  • "pt-PT": Portuguese (Portugal)
  • "ro": Romanian, Moldavian, Moldovan
  • "ru": Russian
  • "sa": Sanskrit
  • "sh": Serbo-Croatian
  • "si": Sinhala, Sinhalese
  • "sk": Slovak
  • "sl": Slovenian, Slovene
  • "so": Somali
  • "sq": Albanian
  • "sr": Serbian
  • "sv": Swedish
  • "sw": Swahili (macrolanguage)
  • "ta": Tamil
  • "te": Telugu
  • "th": Thai
  • "tl": Tagalog
  • "tlh": Klingon, tlhIngan-Hol
  • "tn": Tswana, Setswana
  • "tr": Turkish
  • "ts": Tsonga
  • "tw": Twi
  • "uk": Ukrainian
  • "ur": Urdu
  • "uz": Uzbek
  • "ve": Venda
  • "vi": Vietnamese
  • "xh": Xhosa
  • "zh": Chinese
  • "zh-TW" Chinese (Taiwan)
  • "zu": Zulu

Feedback

If you find any bugs or issues please file them on this project and I'll take a look.

Please also feel free to catch me on Twitter @richtibbett.

More Repositories

1

NoSleep.js

Prevent display sleep and enable wake lock in any Android or iOS web browser.
JavaScript
2,122
star
2

threeVR

An orientation-aware Virtual Reality controller for web browsers built on top of three.js
JavaScript
436
star
3

baseapp

Bootstrap-based web application scaffolding built in Go on top of the Revel Web Framework w/ Docker build support
Go
91
star
4

Marine-Compass

A 3-dimensional floating compass for the web
JavaScript
65
star
5

doe

An emulator for building and debugging device orientation and screen orientation based web applications
JavaScript
49
star
6

plug.play.js

A Network Service Messaging framework for use on top of the W3C Network Service Discovery specification
JavaScript
38
star
7

Opera-Translate

Translate for Opera adds in-page language translation functionality to any web page.
JavaScript
22
star
8

Artificial-Horizon

A JavaScript implementation of an Artifical Horizon Instrument
JavaScript
11
star
9

go-tls-srp

Snapshot of https://bitbucket.org/mjl/go-tls-srp @ 6th Nov 2014
Go
6
star
10

html-media-focus

[DEPRECATED] Connecting remote control interfaces and events with web content
JavaScript
4
star
11

sensortest.org

[DISCONTINUED] How well does your browser support DeviceOrientation Events?
PHP
3
star
12

appearin-handoff-extension

Handoff Appear.in sessions from your desktop to Android mobile web browser
JavaScript
3
star
13

devopera

Repository for Dev.Opera source code
HTML
3
star
14

universal-remote-control-access

A demonstration of how web apps can access media-centric remote control events to control any other web content
JavaScript
3
star
15

Opera-11-Extensions--Auto-I18N-Library

Auto-translation library for Opera 11+ Extensions
JavaScript
2
star
16

docker-jobber

A minimal Docker container for running Jobber (cron-replacement) tasks
2
star
17

Opera-Firebug-Lite-Extension

Firebug Lite extensions for Opera 11+
JavaScript
1
star
18

Browser-to-Phone

Browser to Phone lets you share links, maps, phone numbers and text content between your desktop browser and phone.
Java
1
star