- Author
- Leandro Rabindranath Leon
# include <iostream>
# include <string>
{
const std::string text = "ahishers";
const auto matches = ac.
search(text);
std::cout << "Aho-Corasick Example\n";
std::cout << "Text: " << text << "\n\n";
std::cout << "Matches (position -> pattern):\n";
for (auto [position, pattern_id] : matches)
std::cout << " " << position << " -> "
<< " (id=" << pattern_id << ")\n";
return 0;
}
Multi-pattern string matching with the Aho-Corasick automaton.
Aho-Corasick multi-pattern automaton.
const std::string & pattern(const size_t id) const
Return the pattern text by id.
void build()
Build failure links and transition completion.
size_t add_pattern(std::string pattern)
Add one pattern to the automaton.
Array< Match > search(const std::string_view text) const
Search all patterns in a text.
Main namespace for Aleph-w library functions.