# term-vector

> Creates a term vector from tokenized text.

Latest version **1.0.1** (published 2024-11-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install term-vector
pnpm add term-vector
yarn add term-vector
bun add term-vector
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

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

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-11-28 |
| First published | 2015-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Fergus McDowall |
| Maintainers | fergie |
| Keywords | natural, language, vector, vector space model |

## Links

- npm: https://www.npmjs.com/package/term-vector
- Repository: https://github.com/fergiemcdowall/term-vector
- Issues: https://github.com/fergiemcdowall/term-vector/issues
- npm.io page: https://npm.io/package/term-vector

## Recent versions

- 1.0.1 (latest) — 2024-11-28
- 1.0.0 — 2018-11-25
- 0.1.2 — 2016-08-29
- 0.1.1 — 2016-08-29
- 0.0.18 — 2016-04-05
- 0.0.17 — 2016-04-04
- 0.0.16 — 2016-03-18
- 0.0.15 — 2016-03-16
- 0.0.14 — 2016-03-15
- 0.0.13 — 2016-03-15
- 0.0.12 — 2015-07-06
- 0.0.11 — 2015-07-03
- 0.0.10 — 2015-05-29
- 0.0.9 — 2015-05-29
- 0.0.8 — 2015-05-13
- … 7 more at https://npm.io/package/term-vector/versions

## README

[![NPM version][npm-version-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![MIT License][license-image]][license-url]

# term-vector
A node.js module that creates a term vector from tokenized text. Use `term-vector` when implementing a [vector space model](http://en.wikipedia.org/wiki/Vector_space_model)

**Works with Unicode!**

**Does ngrams!**


```javascript

const tv = require('term-vector') 
// alternatively if you are all fancy and new-fangled:
// import tv from 'term-vector'
const tokens = 'this is really really really cool'.split(' ')

// just make a simple term vector
tv(tokens)
// [
//   { term: [ 'cool' ], positions: [ 5 ] },
//   { term: [ 'is' ], positions: [ 1 ] },
//   { term: [ 'really' ], positions: [ 2, 3, 4 ] },
//   { term: [ 'this' ], positions: [ 0 ] }
// ]

// make a term vector with ngrams of length 1 and 2
tv(tokens, { ngramLengths: [ 1, 2 ] })
// [
//   { term: [ 'cool' ], positions: [ 5 ] },
//   { term: [ 'is' ], positions: [ 1 ] },
//   { term: [ 'is', 'really' ], positions: [ 1 ] },
//   { term: [ 'really' ], positions: [ 2, 3, 4 ] },
//   { term: [ 'really', 'really' ], positions: [ 2, 3 ] },
//   { term: [ 'really', 'cool' ], positions: [ 4 ] },
//   { term: [ 'this' ], positions: [ 0 ] },
//   { term: [ 'this', 'is' ], positions: [ 0 ] }
// ]

```

[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: LICENSE

[npm-url]: https://npmjs.org/package/term-vector
[npm-version-image]: http://img.shields.io/npm/v/term-vector.svg?style=flat
[npm-downloads-image]: http://img.shields.io/npm/dm/term-vector.svg?style=flat

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