Giter Site home page Giter Site logo

whatlang-node's Introduction

whatlang-node

https://github.com/Cattttttttt/whatlang-node/actions

NodeJS binding of whatlang-rs

Usage

Install

npm install @notevenaneko/whatlang-node

or

yarn add @notevenaneko/whatlang-node

or

pnpm add @notevenaneko/whatlang-node

Detect language

import { detect, LangCode, LangCodeISO6391 } from '@notevenaneko/whatlang-node'

const info = detect(englishInput)

info.lang.code === LangCode.Eng
info.lang.codeISO6391 === LangCodeISO6391.En
info.lang.name === 'English'
info.lang.engName === 'English'

info.script.name === 'Latin'

compareFloat(info.confidence, 1) === true

info.isReliable === true

Allowlist and denylist

import { Detector, LangCode } from '@notevenaneko/whatlang-node'

const normalDetector = new Detector()

const chineseDetector = Detector.withAllowlist([LangCode.Cmn /* or LangCodeISO6391.Zh in ISO639-1 */])

normalDetector.detectLang(englishInput).code === LangCode.Eng

chineseDetector.detectLang(englishInput) === null

const noZhDetector = Detector.withDenylist([LangCode.Cmn /* or LangCodeISO6391.Zh in ISO639-1 */])

normalDetector.detectLang(chineseInput).code === LangCode.Cmn

noZhDetector.detectLang(chineseInput).code === LangCode.Jpn

Support matrix

Operating Systems

node14 node16 node18
Windows x64
Windows x32
Windows arm64
macOS x64
macOS arm64
Linux x64 gnu
Linux x64 musl
Linux arm gnu
Linux arm64 gnu
Linux arm64 musl
Android arm64
Android armv7
FreeBSD x64

Bench

Name: Apple M1
Vendor String: Apple
Vendor ID: VendorUnknown
PhysicalCores: 8
Threads Per Core: 1
Logical Cores: 8
CPU Family 458787763 Model: 0 Stepping: 0
Features: AESARM,ASIMD,ASIMDDP,ASIMDHP,ASIMDRDM,ATOMICS,CRC32,DCPOP,FCMA,FP,FPHP,GPA,JSCVT,LRCPC,PMULL,SHA1,SHA2,SHA3,SHA512
Microarchitecture level: 0
Cacheline bytes: 128
L1 Instruction Cache: 131072 bytes
L1 Data Cache: 65536 bytes
L2 Cache: 4194304 bytes
L3 Cache: -1 bytes

Running "Detect language" suite...
Progress: 100%

  languagedetect:
    10 799 ops/s, ±3.38%   | slowest, 38.05% slower

  whatlang-node:
    17 432 ops/s, ±0.97%   | fastest

  @notevenaneko/whatlang-node:
    17 294 ops/s, ±0.58%   | 0.79% slower

Finished 3 cases!
  Fastest: whatlang-node
  Slowest: languagedetect

TODO

  • Complete Script enum and constructor
  • documentation

whatlang-node's People

Contributors

notevenaneko avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.