fasttext-js
Node.js interface for fastText
Setup
We can install fasttext-js
locally by running:
npm install --save fasttext-js
or
yarn add fasttext-js
Usage
import { predictAsync, trainAsync } from 'fasttext-js';
const dataPath = './inbound.txt';
const modelPath = './model.bin';
trainAsync(dataPath, modelPath)
.then(() => {
const messages = [
'Opt in',
'Opt out'
];
return predictAsync(modelPath, messages);
})
.then(({ predictions }) => {
console.log(predictions);
})
.catch((err) => {
console.log(err);
});
References
Train supervised text classifiers with txt file at dataPath
and store model to modelPath
.
trainAsync(dataPath, modelPath)
Obtain the most likely label for an array of of sentences
with confidence rate using model at modelPath
.
predictAsync(modelPath, sentences)