Socket
Socket
Sign inDemoInstall

lang-detect

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lang-detect

a tool to detecting the language for a small piece of unicode text without any dependency to other libraries.


Maintainers
1

lang-detect: a tool to detect language

Detecting the language for a small piece of unicode text without any dependency to other libraries.

Currently we support detecting de, en, es, fr, it, ja, nl, pl, ru, zh-hans, zh-hant, and zh-yue.

After some simple testing, we found that the result for long sentence is better.

Method

We focus on the Basic Multilingual Plane in unicode encoding, and current language support set could be extended.

For each language, we use a uniformed ngram vector to represent the language itself. This vector can be seen at the data folder.

When we detect a text, we generate the uniformed ngram vector for this text, and just comparing the cosine value of the angle between the text vector and the language vector.

To get the language vector, we use feature articles on Wikipedia as corpus.

Usage

cd to the project root

bin/langdetect YOUR_SENTENCE_HERE

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc