You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

fasttext-native

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fasttext-native

fastText bindings for Node.js

0.2.2
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

fasttext-native

fastText native bindings for ⬡.js

npm Travis David

Forked from pragonauts's fast-text

Features

  • Executing prediction models
  • Searching nearest neighbour
  • Prebuilt binaries for Linux and macOS (Windows is not supported by fastText)
  • Tracking latest fastText upstream version (currently version 0.1.0)

Usage

Prediction

There is a simple class for executing prediction models:

const path = require('path')
const { Classifier } = require('fasttext-native')

const model = path.resolve(__dirname, './classification.bin')

const classifier = new Classifier(model)

classifier.predict('how it works', 1, (err, res) => {
  if (err) {
    console.error(err)
  } else if (res.length > 0) {
    const tag = res[0].label // __label__someTag
    const score = res[0].valuel // 1.3455345
  } else {
    console.log('No matches')
  }
})

Nearest neighbour

There is a simple class for searching nearest neighbours:

const path = require('path')
const { Query } = require('fasttext-native')

const model = path.resolve(__dirname, './skipgram.bin')

const query = new Query(model)

query.nn('word', 10, (err, res) => {
  if (err) {
    console.error(err)
  } else if (res.length > 0) {
    const tag = res[0].label // letter
    const score = res[0].valuel // 0.99992
  } else {
    console.log('No matches')
  }
})

Keywords

fasttext

FAQs

Package last updated on 04 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts