53 const std::string text =
"ahishers";
54 const auto matches = ac.
search(text);
56 std::cout <<
"Aho-Corasick Example\n";
57 std::cout <<
"Text: " << text <<
"\n\n";
59 std::cout <<
"Matches (position -> pattern):\n";
60 for (
auto [position, pattern_id] : matches)
61 std::cout <<
" " << position <<
" -> "
63 <<
" (id=" << pattern_id <<
")\n";
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.