# fast-text

> Facebook FastText wrapper for Node.js

Latest version **1.0.3** (published 2022-12-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install fast-text
pnpm add fast-text
yarn add fast-text
bun add fast-text
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-12-21 |
| First published | 2017-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 148.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 11 |
| Author | David Menger |
| Maintainers | davidmenger, wingbot.ai |
| Keywords | TextProcessing, FastText, Facebook |

## Links

- npm: https://www.npmjs.com/package/fast-text
- Repository: https://github.com/davidmenger/fast-text
- Homepage: https://github.com/davidmenger/fast-text#readme
- Issues: https://github.com/davidmenger/fast-text/issues
- npm.io page: https://npm.io/package/fast-text

## Dependencies (2)

- [nan](https://npm.io/package/nan.md) ^2.17.0
- [bindings](https://npm.io/package/bindings.md) ^1.5.0

## Recent versions

- 1.0.3 (latest) — 2022-12-21
- 1.0.3-alpha.1 (next) — 2022-12-21
- 1.0.2 — 2022-11-03
- 1.0.1 — 2021-06-28
- 1.0.0 — 2020-01-14
- 1.0.0-alpha.2 — 2019-03-12
- 1.0.0-alpha.1 — 2019-03-12
- 0.1.0 — 2017-12-18
- 0.0.5 — 2017-08-23
- 0.0.4 — 2017-08-07
- 0.0.3 — 2017-07-19
- 0.0.3-alpha4 — 2017-07-19
- 0.0.3-alpha3 — 2017-07-19
- 0.0.3-alpha2 — 2017-07-19
- 0.0.3-alpha1 — 2017-07-19
- … 1 more at https://npm.io/package/fast-text/versions

## README

# Node.js Fast Text Wrapper

Prediction and nearest neighbour tools from Facebook Fast Text wrapped into Node.js packages.

More here: [Facebook Fast Text](https://github.com/facebookresearch/fastText).

First query takes more time, other queries not :)

## Prediction

There is a simple class for executing prediction models:

```javascript
const path = require('path');
const { Classifier } = require('../main');

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('../main');

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');
    }
});
```

---
_Source: https://npm.io/package/fast-text · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
