-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdfa_test.py
More file actions
59 lines (56 loc) · 1.19 KB
/
dfa_test.py
File metadata and controls
59 lines (56 loc) · 1.19 KB
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
from pythomata import SimpleDFA
alphabet = {"日", "本", "人"}
states = {"s1", "s2", "s3"}
initial_state = "s1"
accepting_states = {"s3"}
transition_function = {
"s1": {
"日":"s1",
"本" : "s2"
},
"s2": {
"人" : "s3",
"本" : "s2"
},
"s3":{
"人" : "s3"
}
}
dfa = SimpleDFA(states, alphabet, initial_state, accepting_states, transition_function)
word = "日本女人"
print(dfa.accepts(word))
state_event_dict = {
"匹": {
"配": {
"算": {
"法": {
"is_end": True
},
"is_end": False
},
"关": {
"键": {
"词": {
"is_end": True
},
"is_end": False
},
"is_end": False
},
"is_end": False
},
"is_end": False
},
"信": {
"息": {
"抽": {
"取": {
"is_end": True
},
"is_end": False
},
"is_end": False
},
"is_end": False
}
}