Unofficial Node.js bindings for Compact Language Detector v3 (CLD3).
The library exposes a getLanguages
function that returns the detected languages in the provided text.
This is an unofficial wrapper around the CLD3 library. It is not affiliated with Google in any way.
Installation: npm install cld3
import { getLanguages } from 'cld3';
const langs = getLanguages(
'This piece of text is in English. Гэты тэкст на беларускай мове.'
);
console.log(langs);
/**
* [
* {
* language: 'be',
* probability: 0.9173873066902161,
* is_reliable: true,
* proportion: 0.5853658318519592
* },
* {
* language: 'en',
* probability: 0.9999790191650391,
* is_reliable: true,
* proportion: 0.4146341383457184
* }
* ]
*/
- Ensure you are using Node.js >= 18 and have the protobuf, clang and cmake installed
- Install dependencies
npm install
- Compile bindings
npm run build
- Run the tests
npm run test
or use Docker
docker build . -t node-cld3:node
docker run --rm -it node-cld3:node