JSPM

eld-custom

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q42511F
  • License Apache-2.0

Fast and accurate natural language detection. Detector written in Javascript. Efficient language detector, Nito-ELD, ELD.

Package Exports

  • eld-custom
  • eld-custom/src/languageDetector.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eld-custom) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

forked from https://github.com/nitotm/efficient-language-detector-js

使い方

import { eld } from './src/languageDetector.js';

await eld.init("ngramsM60-subset-de-en-es-fr-it-ja-ko-pt-zh.js");
const result = eld.detect('Hello world');
console.log(result.language); // 'en'

サブセット生成

  1. generateSubset.js内の以下の部分を修正して、サブセットに含めたい言語を指定。精度を高めたい場合はbaseNgramFileNameをLにする
const defaultLanguages = ["en", "ja", "zh", "es", "ko", "fr", "de", "pt", "it"];
node generateSubset.js

=> ngrams-main.jsが更新される

テスト

node test-detection.js