trigram-utils / 0.0.2 last updated 2 months ago created on Sep 19th 2014
Install
npm install --save trigram-utils
Clone
git clone git@github.com:wooorm/trigram-utils.git
maintainers
versions
| 0.0.2 | 2 months ago | wooorm |
| 0.0.1 | 2 months ago | wooorm |
readme
trigram-utils
Some trigram language statistics utility functions.
They have their own repo here to make sure wooorm/trigrams (trigram information for the Universal Declaration of Human Rights) and wooorm/franc (language detection) use the same cleaning and classification methods.
Installation
npm:
Component:
Bower:
Usage
API
trigramUtils.clean(string)
Cleans a given string: strips certain (for language detection) useless punctuation, symbols, and numbers. Concatenated extraneous white space, trims, lowercases, and pads (with one space on both sides).
trigramUtils.trigrams(string)
Gets cleaned trigrams (see wooorm/n-gram).
trigramUtils.asDictionary(string)
Gets cleaned trigrams as a dictionary: the keys of the objects are trigrams, the values are occurrence counts.
trigramUtils.asTuples(string)
Gets cleaned trigrams with occurrence counts as a tuple: the first indice (0) being the trigram, the second (1) the occurrence count.
trigramUtils.tuplesAsDictionary(Array.\>)
Transforms an array of trigram–occurrence tuples (as returned by trigramUtils.asTuples(string)) as a dictionary (see trigramUtils.asDictionary(string));
License
MIT © Titus Wormer