-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot_test.py
More file actions
104 lines (84 loc) · 3.64 KB
/
bot_test.py
File metadata and controls
104 lines (84 loc) · 3.64 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
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
94
95
96
97
98
99
100
101
102
103
104
import pickle
import time
import local_database.fb_sql as db
from parser.fb_parser import CHECK
clf_ex, clf_in = pickle.load(open('data_define\\categorizer.data', 'rb'))
ct_ex_list, ct_in_list, subct_ex_dict, subct_in_dict = \
pickle.load(open('local_database\\cts_lists.data', 'rb'))
check_list = ['INSERT_YOUR_RECEIPT_HERE']
if __name__ == '__main__':
print("{:0>4.4s}-{:0>2.2s}-{:0>2.2s}-{:0>2.2s}-{:0>2.2s}"
.format(*map(str, (2022, 1, 30, 0, 1))))
def define_cts_ex(oper_name):
ct = clf_ex.predict([oper_name])[0]
print(*it, sep=' ')
while True:
q = input(f'The category for {it[0]} is {ct}.\n'
f'1. Change category\n2. Set subcategory\n')
if q == '1':
t_ex = ''.join([f'{i + 1}. {c}\n'
for i, c in enumerate(ct_ex_list)])
ct = ct_ex_list[
int(input('Enter one fo the next categories '
f'for {it[0]}:\n{t_ex}')) - 1]
elif q == '2':
t_ex = ''.join([f'{i + 1}. {c}\n'
for i, c in enumerate(subct_ex_dict[ct])])
subct = input('Enter one fo the next subcategories '
f'for {it[0]} \neither type '
'your own category \neither type whitespace '
'for no subcategory\nor type "cansel" '
f'for returning back:\n{t_ex}')
if subct.lower() == 'cansel':
continue
if subct == ' ':
subct = None
break
elif subct.isdigit():
subct = subct_ex_dict[ct][int(subct) - 1]
break
else:
break
return ct, subct
for qr in check_list:
st = time.perf_counter()
t = CHECK(qr)
li = t.get_list()
date = t.date()
print(date)
if not li:
q = input('Information from the check wasn\'t loaded.\n'
'1. Pass\n2. Enter information on your own '
'by the scheme below:\noperation name, '
'price per unit, amount, total cost '
'(separateing each parameter by three whitespaces '
'like this \/).\n'
'Мука Белиевская в/с 2кг 1/ 82.00 1 82.00\n'
'Салфетки комфорт бум б/рис 21.00 2 42.00\n'
'Яблоки 159.90 0.866 138.47\n'
' 100 1 100 (you can pass name by this way)\n')
if q == '1':
continue
if q == '2':
i = 0
while q.lower() != 'end':
i += 1
op = input(f'Enter operation {i}: ')
op = op.split(' ')
ct, subct = define_cts_ex(op[0])
operation = ('1', date, op[0], *map(float, op[1:]),
ct, subct)
db.add_operation(operation)
print(f'Operation {operation[2]} / {ct} / {subct} '
'added successfully!')
q = input('If you want to exit type word "end",'
' type any message otherwise:\n')
continue
print(time.perf_counter() - st)
for it in li:
ct, subct = define_cts_ex(it[0])
operation = ('1', date, it[0].strip(), *it[1:], ct, subct)
db.add_operation(operation)
print(f'Operation {operation[2]} / {ct} / {subct} '
'added successfully!\n\n')
# 28.367970580002293 10/15 are right