|
@@ -71,7 +71,7 @@ def rule4_decorator(f, *args, **kwargs):
|
|
|
predict_line = args[1]
|
|
|
predict_line = f(*args, **kwargs)
|
|
|
try:
|
|
|
- if '项目' in predict_line[1] and predict_line[0]=='':
|
|
|
+ if '项目' in predict_line[1] and predict_line[0] == '':
|
|
|
predict_line[0] = '项目'
|
|
|
predict_line[1] = predict_line[1].replace('项目', '')
|
|
|
except IndexError as e:
|
|
@@ -87,10 +87,11 @@ def rule5_decorator(f, *args, **kwargs):
|
|
|
predict_line = args[1]
|
|
|
predict_line = f(*args, **kwargs)
|
|
|
try:
|
|
|
- if '项目' in predict_line[0] and '营养素参考值' in predict_line[1] and len(predict_line[1])>7 and predict_line[2] == '':
|
|
|
+ if '项目' in predict_line[0] and '营养素参考值' in predict_line[1] and len(predict_line[1]) > 7 and \
|
|
|
+ predict_line[2] == '':
|
|
|
predict_line[2] = '营养素参考值'
|
|
|
- if len(predict_line[1].split('营养素参考值'))>1:
|
|
|
- predict_line[2] = predict_line[2]+predict_line[1].split('营养素参考值')[1]
|
|
|
+ if len(predict_line[1].split('营养素参考值')) > 1:
|
|
|
+ predict_line[2] = predict_line[2] + predict_line[1].split('营养素参考值')[1]
|
|
|
predict_line[1] = predict_line[1].split('营养素参考值')[0]
|
|
|
except IndexError as e:
|
|
|
print('rule5_decorator', e)
|
|
@@ -113,7 +114,42 @@ def rule6_decorator(f, *args, **kwargs):
|
|
|
predict_line[1] = predict_line[2].split('营养素参考值')[0]
|
|
|
r = predict_line[2].split('营养素参考值')
|
|
|
if len(r) == 2:
|
|
|
- predict_line[2] = '营养素参考值'+r[1]
|
|
|
+ predict_line[2] = '营养素参考值' + r[1]
|
|
|
+ except IndexError as e:
|
|
|
+ print('rule6_decorator', e)
|
|
|
+ return predict_line
|
|
|
+
|
|
|
+@decorator
|
|
|
+def rule7_decorator(f, *args, **kwargs):
|
|
|
+ '''
|
|
|
+ predict_line = ['项目 ', '', '每份(70g)营养素参考值%', '']
|
|
|
+ '''
|
|
|
+ predict_line = f(*args, **kwargs)
|
|
|
+ print('-=-=', predict_line)
|
|
|
+ try:
|
|
|
+ if '项目' in predict_line[0] or '项' in predict_line[0] or '目' in predict_line[0]:
|
|
|
+ predict_line[0] = '项目'
|
|
|
+ except IndexError as e:
|
|
|
+ print('rule6_decorator', e)
|
|
|
+ return predict_line
|
|
|
+
|
|
|
+@decorator
|
|
|
+def rule8_decorator(f, *args, **kwargs):
|
|
|
+ '''
|
|
|
+ predict_line = ['项目 ', '', '每份(70g)营养素参考值%', '']
|
|
|
+ '''
|
|
|
+ predict_line = f(*args, **kwargs)
|
|
|
+ print('-=-=', predict_line)
|
|
|
+ try:
|
|
|
+ if len(predict_line) >= 3 \
|
|
|
+ and '' == predict_line[0] \
|
|
|
+ and '' in predict_line[1] \
|
|
|
+ and ('项' in predict_line[2] or '目' in predict_line[2]) \
|
|
|
+ and ('100' in predict_line[2] or '克' in predict_line[2]) \
|
|
|
+ and '营养' in predict_line[2]:
|
|
|
+ predict_line[0] = '项目'
|
|
|
+ predict_line[1] = '每100克'
|
|
|
+ predict_line[2] = '营养素参考值%'
|
|
|
except IndexError as e:
|
|
|
print('rule6_decorator', e)
|
|
|
return predict_line
|
|
@@ -138,4 +174,5 @@ register_decorator(rule3_decorator)
|
|
|
register_decorator(rule4_decorator)
|
|
|
register_decorator(rule5_decorator)
|
|
|
register_decorator(rule6_decorator)
|
|
|
-
|
|
|
+register_decorator(rule7_decorator)
|
|
|
+register_decorator(rule8_decorator)
|