@monyone/aho-corasick
v1.1.3
Published
Aho Corasick implementation written in TypeScript
Readme
aho-corasick
Simple Aho-Corasick algorhythm implementaiton for TypeScript.
Getting Started
npm i @monyone/aho-corasickKeyword Detection
import { AhoCorasick } from '@monyone/aho-corasick';
const ahocorasick = new AhoCorasick(keywords);
const hasAnyKeyword: boolean = ahocorasick.hasKeywordInText(text);Keyword Matching
import { AhoCorasick } from '@monyone/aho-corasick';
const ahocorasick = new AhoCorasick(keywords);
const match: { begin: number, end: number, keyword: string}[] = ahocorasick.matchInText(text);Dynamic Addition/Deletion
import { DynamicAhoCorasick } from '@monyone/aho-corasick';
const ahocorasick = new DynamicAhoCorasick(keywords);
ahocorasick.add('test')
ahocorasick.delete('test')
const match: { begin: number, end: number, keyword: string}[] = ahocorasick.matchInText(text);Greedy (Leftmost-Longest) Match Variant
import { AhoCorasick } from '@monyone/aho-corasick/greedy';
const ahocorasick = new AhoCorasick(keywords);
const match: { begin: number, end: number, keyword: string}[] = ahocorasick.matchInText(text);More Faster Search (Double Array)
import { AhoCorasick } from '@monyone/aho-corasick/fast';
const ahocorasick = new AhoCorasick(keywords);
const match: { begin: number, end: number, keyword: string}[] = ahocorasick.matchInText(text);