-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
93 lines (70 loc) · 1.6 KB
/
main.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"""The Sequences() class example"""
from src.sequences import Sequences
from src.frames import mass_frame, single_frames
from tests import run_test
# Detect these words within an input stream.
WORDSA = ('apples',
'window',
'ape',
'apex',
'extra',
'tracks',
'stack',
'yes',
'cape',
'cake',
'echo',
'win',
# 'horse',
# 'house',
'wind',
'windy',
'w',
'ww',
'd' * 5,)
def sink(v):
print('Sink', v)
return True
def vowel(v):
return v in 'aieou'
WORDS2 = (
('w', 'i', 'n', 'd', 'o', 'w',),
'windy',
('q', sink, 'd'),
('c', vowel, 't',),
)
def main():
run_test(WORDSA)
sq = Sequences(WORDSA, id_func=id)
# ask_loop(sq)
return sq
from src.sequence import Sequence, Path
WORDS = (
Sequence('cake', Path('w', 'i', 'n')),
)
sq = Sequences(WORDS)
from src.sequence import Sequence, Path
WORDS = (
Sequence('cake', Path('w', 'i', 'n')),
Path('w', 'i', 'n'),
)
sq = Sequences(WORDS)
sq.insert_key('w')
def ask_loop(sequences):
while 1:
try:
ask_inject(sequences)
except (EOFError, KeyboardInterrupt) as e:
print('Close ask-loop')
return
return sequences
def ask_inject(sequences):
v = input('?: ')
return push(sequences, v)
def push(sequences, v):
r = single_frames(sequences, v)
# r = mass_frame(sequences, v)
starts, matches, drops = r
print(f"{starts=}\n{matches=}\n{drops=}")
if __name__ == '__main__':
r = main()