predictionary
Version:
JavaScript dictionary-based word prediction library.
42 lines (28 loc) • 1.63 kB
Markdown
JavaScript dictionary-based word prediction library with self-learning abilities.
Drop the following into your page:
```html
<script src="https://unpkg.com/predictionary/dist/predictionary.min.js"></script>
```
or install the package via npm:
```
npm install predictionary --save
```
*Note:* to use inside a nodejs application use the flag `--experimental-modules` in order to be able to use Predictionary which is written as ES6 module. See [nodejs demo](https://github.com/asterics/predictionary/blob/master/demo/node-demo/app.mjs) which can be run with:
`node --experimental-modules demo/node-demo/app.mjs`
Minimum working example for basic usage:
```javascript
import Predictionary from 'predictionary' //only if installed via npm
let predictionary = Predictionary.instance();
predictionary.addWords(['apple', 'apricot', 'banana']);
let suggestions = predictionary.predict('ap'); // == ['apple', 'apricot'];
```
See working demo: [to live demo](https://asterics.github.io/predictionary/demo/)
see full API documentation: [to API documentation](https://asterics.github.io/predictionary/docs/Predictionary.html)
Thanks to Mark Davies, Professor of Linguistics at Brigham Young University (Utah), for the permission to use his n-gram sample data from https://www.ngrams.info/iweb.asp for training purposes of this library.
Word frequency lists for demos are taken from the Centre for Translation Studies, University of Leeds, see http://corpus.leeds.ac.uk/list.html - thanks!