A Ruby implementation of the Aho-Corasick string matching algorithm.
Add this line to your application's Gemfile:
gem 'rbahocorasick'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rbahocorasick
require 'rubygems'
require 'rbahocorasick'
nfa = RBAhoCorasick::NFA.new
%w{he she his hers}.each{|key| nfa.add(key)}
nfa.finalize
nfa.match('he and she are friends').each{|m| puts m.key}
Yes, you can use DFA instead of NFA for better performance. See test/tc_nfa.rb
for more examples.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request