strings.aho_corasick

Classes

Automaton

Module Contents

class strings.aho_corasick.Automaton(keywords: list[str])
add_keyword(keyword: str) None
find_next_state(current_state: int, char: str) int | None
search_in(string: str) dict[str, list[int]]
>>> A = Automaton(["what", "hat", "ver", "er"])
>>> A.search_in("whatever, err ... , wherever")
{'what': [0], 'hat': [1], 'ver': [5, 25], 'er': [6, 10, 22, 26]}
set_fail_transitions() None
adlist: list[dict] = []