Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

langdetect-ensemble

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

langdetect-ensemble

<!--This file is generated by `build.js`-->

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

langdetect-ensemble

Detect the language of text, support ensembling of multiple models through fastText. langdetect-ensemble uses Franc by default in case no language models are loaded

Install

npm:

npm install langdetect-ensemble

Usage

Loading the library:

var fs = require('fs'); // Use to automatically load all models from given folder
var lang = require('langdetect-ensemble')

Initializing LangDetect object:

var dir_models = __dirname + '/path/to/your/model/folder/'
langDet = new lang.langDetect()

fs.readdirSync(dir_models).forEach(function(file) {
      let model_file = dir_models +'/'+file;
      try {
        langDet.addModel(model_file)
      } catch (error) {
        console.log(error);
      }
  });

Setting weights of model:

langDet.addModel('./lid.176.ftz')
langDet.setWeights([0.3, 0.7]) // Here, a vote by franc counts for 0.3, and a vote by the FastText model counts for 0.7

Using LangDetect object for language detection:

langDet.predict('chào buổi sáng').then((lang) => {
    console.log(lang);
    // expected output: 'vie'
});

License

MIT © [Cuong V Nguyen]

Keywords

FAQs

Package last updated on 01 Jun 2021

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