mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-30 16:31:08 +00:00
Update aho-corasick.py (#1457)
This commit is contained in:
parent
182062d60b
commit
3ea0992dc7
|
@ -54,7 +54,7 @@ class Automaton:
|
||||||
self.adlist[child]["fail_state"] = self.find_next_state(
|
self.adlist[child]["fail_state"] = self.find_next_state(
|
||||||
state, self.adlist[child]["value"]
|
state, self.adlist[child]["value"]
|
||||||
)
|
)
|
||||||
if self.adlist[child]["fail_state"] == None:
|
if self.adlist[child]["fail_state"] is None:
|
||||||
self.adlist[child]["fail_state"] = 0
|
self.adlist[child]["fail_state"] = 0
|
||||||
self.adlist[child]["output"] = (
|
self.adlist[child]["output"] = (
|
||||||
self.adlist[child]["output"]
|
self.adlist[child]["output"]
|
||||||
|
@ -71,7 +71,7 @@ class Automaton:
|
||||||
current_state = 0
|
current_state = 0
|
||||||
for i in range(len(string)):
|
for i in range(len(string)):
|
||||||
while (
|
while (
|
||||||
self.find_next_state(current_state, string[i]) == None
|
self.find_next_state(current_state, string[i]) is None
|
||||||
and current_state != 0
|
and current_state != 0
|
||||||
):
|
):
|
||||||
current_state = self.adlist[current_state]["fail_state"]
|
current_state = self.adlist[current_state]["fail_state"]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user