MCPcopy
hub / github.com/TheAlgorithms/Python / __init__

Method __init__

strings/aho_corasick.py:7–15  ·  view source on GitHub ↗
(self, keywords: list[str])

Source from the content-addressed store, hash-verified

5
6class Automaton:
7 def __init__(self, keywords: list[str]):
8 self.adlist: list[dict] = []
9 self.adlist.append(
10 {"value": "", "next_states": [], "fail_state": 0, "output": []}
11 )
12
13 for keyword in keywords:
14 self.add_keyword(keyword)
15 self.set_fail_transitions()
16
17 def find_next_state(self, current_state: int, char: str) -> int | None:
18 for state in self.adlist[current_state]["next_states"]:

Callers

nothing calls this directly

Calls 3

add_keywordMethod · 0.95
set_fail_transitionsMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected