|
@@ -118,3 +118,61 @@ def rule6_decorator(f, *args, **kwargs):
|
|
except IndexError as e:
|
|
except IndexError as e:
|
|
print('rule6_decorator', e)
|
|
print('rule6_decorator', e)
|
|
return predict_line
|
|
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
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+decorators = []
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def register_decorator(dtor):
|
|
|
|
+ decorators.append(dtor)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def combined_decorator(func):
|
|
|
|
+ for dtor in reversed(decorators):
|
|
|
|
+ func = dtor(func)
|
|
|
|
+ return func
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+register_decorator(rule1_decorator)
|
|
|
|
+register_decorator(rule2_decorator)
|
|
|
|
+register_decorator(rule3_decorator)
|
|
|
|
+register_decorator(rule4_decorator)
|
|
|
|
+register_decorator(rule5_decorator)
|
|
|
|
+register_decorator(rule6_decorator)
|
|
|
|
+register_decorator(rule7_decorator)
|
|
|
|
+register_decorator(rule8_decorator)
|