Skip to content

xudejian/aho-corasick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Build Status Bitdeli Badge

aho-corasick - Aho–Corasick string matching algorithm

#Installation

$ npm install aho-corasick

#Example

##coffee

  • search

      ac = new AhoCorasick()
      ac.add word, word:word for word in ['say', 'she', 'shr', 'he', 'her']
      ac.build_fail()
    
      actual = {}
    
      ac.search 'yasherhs', (found_word)->
      	actual[found_word] ?= 0
      	actual[found_word]++
    
  • build graphviz dot

      ac = new AhoCorasick()
      ac.add word, word:word for word in ['say', 'she', 'shr', 'he', 'her']
      ac.build_fail()
      console.log ac.to_dot()
    

    # save output as trie.dot and

      $ dot -Tpng trie.dot -o trie.png
    

    You also need to install GraphViz

Author

Dejian Xu Google+

##Thanks

##References wikipedia: Aho-Corasick

Releases

No releases published

Packages

No packages published