1.0.0-alpha.1 • Published 7 years ago

node-fasttext v1.0.0-alpha.1

Weekly downloads
9
License
-
Repository
-
Last release
7 years ago

node-fasttext

npm install --save node-fasttext

To import: var FastText = require('node-fasttext');

Training

let config = { 
  dim: 100,
  input: "data/dbpedia.train",
  output: "dbpedia"
}

FastText.train("supervised", config, function (success, error) {

  if(error) {
    console.log(error)
    return;
  }
  
  console.log(success)
  
})

Print Vector

FastText.printVectors(
"dbpedia.bin",
['word', 'word', 'another', 'words', 'here'],
function (success, error) {

  if(error) {
    console.log(error)
    return;
  }

  console.log(success.length)
})

Print model info

FastText.modelInfo("dbpedia.bin", function (success, error) {

  if(error) {
    console.log(error)
    return;
  }
  
  console.log(success)
  
})

Test a model

FastText.test("dbpedia.bin", "data/dbpedia.test", 1, function (data, error) {
  if(error) {
    console.log(error)
    return;
  }
  console.log(data)
  
});

Predict

FastText.predict(
"dbpedia.bin", 1,
['cola lukei , cola lukei is a species of flowering plant in the malvaceae family . it is found only in tanzania . its natural habitat is subtropical or tropical moist lowland forests . it is threatened by habitat loss .'],
function (success, error) {

  if(error) {
    console.log(error)
    return;
  }

  console.log(success[0].label == '__label__11')
  console.log(success)
})