monyone / aho-corasick

aho-corasick implementation for TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

aho-corasick implementation for TypeScript

License:MIT License


Languages

Language:TypeScript 100.0%