recursive long test1 in C00
This commit is contained in:
parent
521708dae4
commit
3f3c3da759
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -1,6 +1,7 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"csvfile",
|
||||
"setrecursionlimit",
|
||||
"testnfa"
|
||||
],
|
||||
"[plaintext]": {
|
||||
|
@ -5,7 +5,9 @@ from tokenize import Comment
|
||||
from numpy import append
|
||||
|
||||
DEBUG = False
|
||||
alfabet = "a"
|
||||
alfabet = "xyz"
|
||||
|
||||
sys.setrecursionlimit(4100)
|
||||
|
||||
|
||||
def print_debug(*args, **kwargs):
|
||||
@ -15,9 +17,9 @@ def print_debug(*args, **kwargs):
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print("Default arguments parsed\n")
|
||||
sys.argv.append("test1.arg")
|
||||
sys.argv.append("test1.in")
|
||||
sys.argv.append("test1.exp")
|
||||
sys.argv.append("long.arg")
|
||||
sys.argv.append("long.in")
|
||||
sys.argv.append("long.exp")
|
||||
|
||||
with open(sys.argv[1], mode="r", newline="", encoding="utf8") as csvfile:
|
||||
filereader = csv.reader(csvfile, delimiter="\t", quotechar="|")
|
||||
@ -49,9 +51,10 @@ with open(sys.argv[1], mode="r", newline="", encoding="utf8") as csvfile:
|
||||
print_debug(
|
||||
f"WARNING - duplicate letter: key = ({item[0]} | {letter}) | line: {num + 1}"
|
||||
)
|
||||
fsa_description_map[tuple].append(item[1])
|
||||
tuple = (item[0], letter)
|
||||
# fsa_description_map[tuple].append(item[1])
|
||||
fsa_description_map[tuple] = item[1]
|
||||
fsa_description_map[tuple] = [item[1]]
|
||||
|
||||
if is_error:
|
||||
exit(-1)
|
||||
@ -108,7 +111,7 @@ def traverse_states(current_state: str, word: str) -> str:
|
||||
ending_state = traverse_states(next_state, word[1:])
|
||||
if is_correct(ending_state):
|
||||
return ending_state # found a correct state
|
||||
return "-1" # no correct state found
|
||||
return "-2" # no correct state found
|
||||
else:
|
||||
return "-1" # unspecified next state
|
||||
return current_state # end of the word
|
||||
@ -118,13 +121,7 @@ is_difference = []
|
||||
for i, word in enumerate(test_in):
|
||||
current_state = "0"
|
||||
if len(word) != 0:
|
||||
for letter in word:
|
||||
if (current_state, letter) in fsa_description_map:
|
||||
current_state = fsa_description_map[(current_state, letter)]
|
||||
else:
|
||||
current_state = "-1"
|
||||
break
|
||||
# ending_state = traverse_states(current_state, word)
|
||||
current_state = traverse_states(current_state, word)
|
||||
|
||||
print(str(i + 1) + "\t", end="")
|
||||
if current_state in accepting_state:
|
||||
|
Loading…
Reference in New Issue
Block a user