t9-plus
TypeScript icon, indicating that this package has built-in type declarations

3.1.3 • Public • Published

T9 Plus

Word prediction for T9 keyboard.

Install

yarn add t9-plus

Usage

With Naive Dictionary

const { T9Search } = require("t9-plus");

const t9 = new T9Search();

const words = ["animal", "baseball", "capital", "elephant", "morning"];

t9.setDict(words);

console.log(t9.predict("6666"));

With Unigram Language Model

yarn add unigram
const { T9Search } = require("t9-plus");
const { unigram } = require("unigram");

const t9 = new T9Search();

const wordsWithWeight = unigram.slice(0, 20000);

const map = new Map();

for (let i = 0; i < wordsWithWeight.length; i++) {
  map.set(wordsWithWeight[i]["word"], wordsWithWeight[i]["freq"]);
}

t9.setDictWithWeight(map);

console.log(t9.predict("6666"));

/t9-plus/

    Package Sidebar

    Install

    npm i t9-plus

    Weekly Downloads

    2

    Version

    3.1.3

    License

    MIT

    Unpacked Size

    6.27 kB

    Total Files

    6

    Last publish

    Collaborators

    • rueihuan