0.0.1 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform
Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.
MIT - MIT LicenseAho-Corasick is a cool algorithm. It is useful when you want to search for many things inside an input text all at once.
For more, see: https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm
graph = AhoCorasick.new(["my", "dictionary", "terms"])
results = AhoCorasick.search(graph, "I wonder if any of the terms from my dictionary appear in this text, and if so, where?")
=> #MapSet<[{"dictionary", 37, 10}, {"my", 34, 2}, {"terms", 23, 5}]>
The result set contains tuple elements in the following format:
{term_found, start_position, run_length}
This is the first non-trivial thing I've written in Elixir. I'm not sure if I'm following style conventions, etc. I think it's a little weird that I used Erlang's :digraph
to implement this. That means the graph structure is not immutable, it's stored in ETS. However, that did make for an interesting adventure into working with a native Erlang library within Elixir, as well as bridging the gap between functional code and imperative/mutable code.