This repository has been archived by the owner on Dec 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
L2_Int1_8_generate_traces.py
69 lines (56 loc) · 2.15 KB
/
L2_Int1_8_generate_traces.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
import os
import re
from L2_Int1_8_automaton import Automaton
from L2_Int1_8_determinization import determinize
from L2_Int1_8_completion import complete
from L2_Int1_8_minimization import minimize
from L2_Int1_8_complementation import complement
from L2_Int1_8_standardization import standardize
FILE_FORMAT = "Int1-8-%d.txt"
OUTPUT_FORMAT = "Int1-8-%d-trace.txt"
def main():
automatas = set()
for file in os.listdir("."):
match = re.match(FILE_FORMAT.replace(r"%d", r"(\d+)"), file)
if match:
automatas.add(int(match.group(1)))
for automaton_id in automatas:
output_path = OUTPUT_FORMAT % automaton_id
with open(output_path, "w") as f:
print(file=f)
print("1. Reading automaton...", file=f)
file_path = FILE_FORMAT % automaton_id
automaton = Automaton.read_from_file(file_path)
automaton.display(file=f)
print(file=f)
print("2. Determinizing and completing automaton...", file=f)
automaton = determinize(automaton, file=f)
automaton = complete(automaton, file=f)
automaton.display(file=f)
print(file=f)
print("3. Minimizing automaton...", file=f)
automaton = minimize(automaton, file=f)
automaton.display(file=f)
print(file=f)
print("4. Starting word recognition...", file=f)
print("This step was skipped in this output file.", file=f)
print("Execute the program to test word recognition by yourself.", file=f)
print(file=f)
print("5. Creating an automaton which recognizes the complementary language...", file=f)
automaton = complement(automaton, file=f)
automaton.display(file=f)
print(file=f)
print("6. Starting word recognition...", file=f)
print("This step was skipped in this output file.", file=f)
print("Execute the program to test word recognition by yourself.", file=f)
print(file=f)
print("7. Standardizing automaton...", file=f)
automaton = standardize(automaton, file=f)
automaton.display(file=f)
print(file=f)
print("8. Starting word recognition...", file=f)
print("This step was skipped in this output file.", file=f)
print("Execute the program to test word recognition by yourself.", file=f)
if __name__ == "__main__":
main()