Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/monyone/aho-corasick
aho-corasick implementation for TypeScript
https://github.com/monyone/aho-corasick
Last synced: 3 months ago
JSON representation
aho-corasick implementation for TypeScript
- Host: GitHub
- URL: https://github.com/monyone/aho-corasick
- Owner: monyone
- License: mit
- Created: 2024-05-31T00:07:33.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-02T06:55:01.000Z (7 months ago)
- Last Synced: 2024-10-05T11:45:44.095Z (3 months ago)
- Language: TypeScript
- Size: 58.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aho-corasick
Simple Aho-Corasick algorhythm implementaiton for TypeScript.
## Getting Started
```sh
npm i @monyone/aho-corasick
```### Keyword Detection
```ts
import { AhoCorasick } from '@monyone/aho-corasick';const ahocorasick = new AhoCorasick(keywords);
const hasAnyKeyword: boolean = ahocorasick.hasKeywordInText(text);
```### Keyword Matching
```ts
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
```ts
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);
```