Code Monkey home page Code Monkey logo

Comments (3)

loretoparisi avatar loretoparisi commented on September 28, 2024 1

@bittlingmayer I will check this out, VSCode has a new functionality that let you convert Promise.then().catch() in the async await pattern.

from fasttext.js.

loretoparisi avatar loretoparisi commented on September 28, 2024 1

@bittlingmayer I have just realized that Node10 has worker threads!!!! that is a huge improvements, and will speed up fastText execution a lot!!! Check this out!

https://github.com/a1xon/Node-Workers-Example/blob/master/worker.js

from fasttext.js.

loretoparisi avatar loretoparisi commented on September 28, 2024

This code snippet show how to use async/await

    let FastText = require('../lib/index');
    let ft = new FastText({
        predict: {
            // k most likely labels for each line <= labels count
            mostlikely: 2,
            verbosity: 2,
            // true to normalize input text before prediction
            normalize: false
        },
        loadModel: MODELS_ROOT + '/lid.176.ftz' // must specifiy filename and ext
    });
    let text = "Bonjour à tous. Ceci est du français";
    // use WASM api
    try {
        await ft.loadWASM();
        var labels = await ft.predictWASM(text);
        console.log("TEXT:", text, "\nPREDICT:", labels);
    } catch (error) {
        console.error("predict error", error);
    }

from fasttext.js.

Related Issues (20)

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.