Skip to content

Instantly share code, notes, and snippets.

@timcowlishaw
Created October 25, 2011 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timcowlishaw/1312074 to your computer and use it in GitHub Desktop.
Save timcowlishaw/1312074 to your computer and use it in GitHub Desktop.
class AhoCorasick #Obviously it's not really, but it has the same behaviour modulo time-complexity
def initialize(terms)
@terms = terms
end
def match(string)
@terms.select {|t| string.include?(t) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment