monyone / aho-corasick

aho-corasick implementation for TypeScript
MIT License
1 stars 0 forks source link

aho-corasick

Simple Aho-Corasick algorhythm implementaiton for TypeScript.

Getting Started

npm i @monyone/aho-corasick

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