https://github.com/tuananh/fasttext-native
fastText native bindings for ⬡.js
https://github.com/tuananh/fasttext-native
fasttext nodejs
Last synced: 6 months ago
JSON representation
fastText native bindings for ⬡.js
- Host: GitHub
- URL: https://github.com/tuananh/fasttext-native
- Owner: tuananh
- Created: 2017-12-03T15:40:23.000Z (almost 8 years ago)
- Default Branch: develop
- Last Pushed: 2017-12-04T15:59:38.000Z (almost 8 years ago)
- Last Synced: 2025-03-24T19:22:07.684Z (7 months ago)
- Topics: fasttext, nodejs
- Language: C++
- Size: 197 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fasttext-native
> fastText native bindings for ⬡.js
[](https://npm.im/fasttext-native)
[](https://travis-ci.org/tuananh/fasttext-native)
[](https://david-dm.org/tuananh/fasttext-native)Forked from [pragonauts's fast-text](https://github.com/pragonauts/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:
```javascript
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:
```javascript
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')
}
})
```