Announcing Lingua 1.4: The most accurate natural language detection library for Rust - now with WASM support

119 points pemistahl

Dear Rustaceans,

I'm happy to announce a new major release of Lingua, the most accurate natural language detection library for Rust. The library can now be compiled to WebAssembly which allows to use it in any JavaScript-based project, be it in the browser or in the back end running on Node.js.

https://github.com/pemistahl/lingua-rs

The easiest way to compile is to use wasm-pack. After the installation, you can, for instance, build the library with the web target so that it can be directly used in the browser:

wasm-pack build --target web

In an HTML file, you can then call Lingua like the following, for instance:

<script type="module">
    import init, { LanguageDetectorBuilder } from './pkg/lingua.js';

    init().then(_ => {
        const detector = LanguageDetectorBuilder.fromAllLanguages().build();
        console.log(
            detector.computeLanguageConfidenceValues("languages are awesome")
        ); 
    });
</script>

Any feedback is highly appreciated. Thanks a lot.

​

https://preview.redd.it/v4lhim099as81.png?width=960&format=png&auto=webp&s=71c5f70cfa29662c6aa547cd52bad2db29b532f7