Skip to content

Commit edfc3b8

Browse files
authored
Add files via upload
1 parent b1100a9 commit edfc3b8

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

script/order_manager.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ def order_manage():
4141
while(1):
4242
order_menu_line = listener()
4343
if '和' in order_menu_line or '個' in order_menu_line:
44-
total_order+=order_menu_line
45-
elif '點完餐' in order_menu_line:
44+
total_order+=order_menu_line+'和'
45+
elif '餐' in order_menu_line:
46+
# 點完餐
4647
break
4748
line_speaker(process_price_with_order(menu_dict, total_order))
4849

script/process_order.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import pandas as pd
22
import re
3+
from setting import chinese_to_arabic
4+
chinese_char_dict = {
5+
'〇' : 0, '一' : 1, '二' : 2, '三' : 3, '四' : 4, '五' : 5, '六' : 6, '七' : 7, '八' : 8, '九' : 9, '零' : 0,
6+
'壹' : 1, '贰' : 2, '叁' : 3, '肆' : 4, '伍' : 5, '陆' : 6, '柒' : 7, '捌' : 8, '玖' : 9, '貮' : 2, '兩' : 2,
7+
}
38
def load_xlsx(file_name = 'menu.xlsx'):
49
xls = pd.ExcelFile(file_name)
510
df = xls.parse(xls.sheet_names[0])
@@ -37,13 +42,21 @@ def process_price_with_order(menu_dict, order):
3742
if top == None:
3843
top = item
3944
else:
45+
if item in chinese_char_dict:
46+
item = chinese_to_arabic(item)
4047
price_dict[top] = {'amount':item, 'price':None}
4148
top = None
4249
else:
4350
if top == None:
4451
top = item
4552
else:
46-
price_dict[item] = {'amount':int(top), 'price':None}
53+
if top in chinese_char_dict:
54+
top = chinese_to_arabic(top)
55+
try:
56+
top = int(top)
57+
except:
58+
top = 0
59+
price_dict[item] = {'amount':top, 'price':None}
4760
top = None
4861

4962
total = 0
@@ -70,6 +83,7 @@ def sum_up_total_line(total, none_list):
7083
return line
7184

7285
# write_xlsx()
73-
data_dict = load_xlsx()
74-
menu_dict = process_data_to_menu(data_dict)
75-
# print(process_price_with_order(menu_dict, '100個火腿和7000個蛋糕'))
86+
# data_dict = load_xlsx()
87+
# menu_dict = process_data_to_menu(data_dict)
88+
# print(process_price_with_order(menu_dict, '100個火腿和7000個蛋糕和兩個大雞雞'))
89+
# print(process_price_with_order(menu_dict, '一個火腿和7000個蛋糕和兩個大雞雞'))

script/setting.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def chinese_to_arabic(chinese_num):
22
chinese_char_dict = {
33
'〇' : 0, '一' : 1, '二' : 2, '三' : 3, '四' : 4, '五' : 5, '六' : 6, '七' : 7, '八' : 8, '九' : 9, '零' : 0,
4-
'壹' : 1, '贰' : 2, '叁' : 3, '肆' : 4, '伍' : 5, '陆' : 6, '柒' : 7, '捌' : 8, '玖' : 9, '貮' : 2, '' : 2,
4+
'壹' : 1, '贰' : 2, '叁' : 3, '肆' : 4, '伍' : 5, '陆' : 6, '柒' : 7, '捌' : 8, '玖' : 9, '貮' : 2, '' : 2,
55
}
66
chinese_char_unit = {
77
'十' : 10,
@@ -46,4 +46,5 @@ def chinese_to_arabic(chinese_num):
4646
val += tmp
4747
return val
4848

49-
# print(chinese_to_arabic("九億七千八百萬八千八百八十八"))
49+
# print(chinese_to_arabic("九億七千八百萬八千八百八十八"))
50+
# print(chinese_to_arabic("一"))

0 commit comments

Comments
 (0)