Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/aho-corasick-automaton
Generates an Aho-Corasick automata for matching multiple patterns in a stream
https://github.com/mikolalysenko/aho-corasick-automaton
Last synced: about 2 months ago
JSON representation
Generates an Aho-Corasick automata for matching multiple patterns in a stream
- Host: GitHub
- URL: https://github.com/mikolalysenko/aho-corasick-automaton
- Owner: mikolalysenko
- License: mit
- Created: 2013-11-06T21:38:23.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-11-06T21:43:16.000Z (about 11 years ago)
- Last Synced: 2024-10-20T14:28:03.141Z (2 months ago)
- Language: JavaScript
- Size: 102 KB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
aho-corasick-automaton
======================
A streaming [Aho-Corasick](http://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm) automata for matching strings. This module is a low level interface, but can be used to construct more complex algorithms.# Example
```javascript
var createTrie = require("array-trie")
var createAC = require("aho-corasick-automaton")var trie = createTrie()
//First build the trie data structure
trie.set([1,2,3], 1)
trie.set([2,3,4], 2)
trie.set([6,7,8], 3)
trie.set([1,2], 4)
trie.set([2,3], 5)//Next construct the automata and use it to
var automata = createAC(trie)//Now run it on some data
var data = [1,2,3,4,5,6,7,8,9]
for(var state=automata, i=0; i