Skip to content

rueihuan/t9-plus

Repository files navigation

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"));

About

Word prediction for T9 keyboard

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published