aho

ahocorasick

Aho-corasick for javascript.

Showing:

Popularity

Downloads/wk

2.6K

GitHub Stars

43

Maintenance

Last Commit

3yrs ago

Contributors

0

Package

Dependencies

0

Size (min+gzip)

0.5KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

ahocorasick

Implementation of the Aho-Corasick string searching algorithm, as described in the paper "Efficient string matching: an aid to bibliographic search".

Installing / Running

npm install ahocorasick

for nodejs:

var AhoCorasick = require('ahocorasick');
var ac = new AhoCorasick(['keyword1', 'keyword2', 'etc']);
var results = ac.search('should find keyword1 at position 19 and keyword2 at position 47.');
// [ [ 19, [ 'keyword1' ] ], [ 47, [ 'keyword2' ] ] ]

or for browsers:

<script src="/src/main.js"><script>`
<script>
var ac = new AhoCorasick(['keyword1', 'keyword2', 'etc']);
...
</script>

check test/basic.js for more examples.

PS. Note that what's returned is the index of the last characters of the found keywords.

Visualization

See https://brunorb.github.io/ahocorasick/visualization.html for an interactive visualization of the algorithm.

License

The MIT License

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100