fix bug
Showing
2 changed files
with
22 additions
and
9 deletions
| ... | @@ -38,7 +38,7 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set): | ... | @@ -38,7 +38,7 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set): |
| 38 | ocr_str = ocr_res.get(compare_tuple[1]) | 38 | ocr_str = ocr_res.get(compare_tuple[1]) |
| 39 | compare_res, ocr_output = getattr(cp, compare_tuple[2])( | 39 | compare_res, ocr_output = getattr(cp, compare_tuple[2])( |
| 40 | input_str, ocr_str, idx, **compare_tuple[3]) | 40 | input_str, ocr_str, idx, **compare_tuple[3]) |
| 41 | if idx == 0 and compare_res == consts.RESULT_N: | 41 | if idx == 0 and compare_res in [consts.RESULT_N, consts.RESULT_NA]: |
| 42 | break | 42 | break |
| 43 | is_find = True | 43 | is_find = True |
| 44 | info_dict[compare_tuple[4]] = compare_res | 44 | info_dict[compare_tuple[4]] = compare_res |
| ... | @@ -70,7 +70,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s | ... | @@ -70,7 +70,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s |
| 70 | ocr_str = ocr_res.get(compare_tuple[1]) | 70 | ocr_str = ocr_res.get(compare_tuple[1]) |
| 71 | compare_res, ocr_output = getattr(cp, compare_tuple[2])( | 71 | compare_res, ocr_output = getattr(cp, compare_tuple[2])( |
| 72 | input_str, ocr_str, idx, **compare_tuple[3]) | 72 | input_str, ocr_str, idx, **compare_tuple[3]) |
| 73 | if idx == 0 and compare_res == consts.RESULT_N: | 73 | if idx == 0 and compare_res in [consts.RESULT_N, consts.RESULT_NA]: |
| 74 | if ocr_str is not None: | 74 | if ocr_str is not None: |
| 75 | no_match_vino.append(ocr_str) | 75 | no_match_vino.append(ocr_str) |
| 76 | break | 76 | break |
| ... | @@ -85,7 +85,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s | ... | @@ -85,7 +85,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s |
| 85 | if not is_find: | 85 | if not is_find: |
| 86 | res_set.add(consts.RESULT_N) | 86 | res_set.add(consts.RESULT_N) |
| 87 | for idx, compare_tuple in enumerate(compare_list): | 87 | for idx, compare_tuple in enumerate(compare_list): |
| 88 | info_dict[compare_tuple[4]] = consts.RESULT_N | 88 | info_dict[compare_tuple[4]] = consts.RESULT_NA |
| 89 | if idx == 0: | 89 | if idx == 0: |
| 90 | continue | 90 | continue |
| 91 | if compare_tuple[0] in info_dict: | 91 | if compare_tuple[0] in info_dict: |
| ... | @@ -194,7 +194,7 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -194,7 +194,7 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
| 194 | 194 | ||
| 195 | comparison_res['OCR_Input']['corporateCusInfo'] = order_corporate_cus_info | 195 | comparison_res['OCR_Input']['corporateCusInfo'] = order_corporate_cus_info |
| 196 | 196 | ||
| 197 | comparison_res['OCR_Input']['wholeResult'] = consts.RESULT_N if consts.RESULT_N in res_set else consts.RESULT_Y | 197 | comparison_res['OCR_Input']['wholeResult'] = consts.RESULT_N if consts.RESULT_N in res_set or consts.RESULT_NA in res_set else consts.RESULT_Y |
| 198 | 198 | ||
| 199 | except Exception as e: | 199 | except Exception as e: |
| 200 | compare_log.error('{0} [compare error] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | 200 | compare_log.error('{0} [compare error] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] ' | ... | ... |
| ... | @@ -35,13 +35,17 @@ class Comparison: | ... | @@ -35,13 +35,17 @@ class Comparison: |
| 35 | return self.RESULT_N | 35 | return self.RESULT_N |
| 36 | 36 | ||
| 37 | def common_compare(self, input_str, ocr_str, idx, **kwargs): | 37 | def common_compare(self, input_str, ocr_str, idx, **kwargs): |
| 38 | if ocr_str == '': | ||
| 39 | return self.RESULT_NA, None | ||
| 38 | if not isinstance(input_str, str) or not isinstance(ocr_str, str): | 40 | if not isinstance(input_str, str) or not isinstance(ocr_str, str): |
| 39 | return self.RESULT_N, ocr_str | 41 | return self.RESULT_NA, ocr_str |
| 40 | return self.build_res(input_str == ocr_str), ocr_str | 42 | return self.build_res(input_str == ocr_str), ocr_str |
| 41 | 43 | ||
| 42 | def name_compare(self, input_str, ocr_str, idx, **kwargs): | 44 | def name_compare(self, input_str, ocr_str, idx, **kwargs): |
| 45 | if ocr_str == '': | ||
| 46 | return self.RESULT_NA, None | ||
| 43 | if not isinstance(input_str, str) or not isinstance(ocr_str, str): | 47 | if not isinstance(input_str, str) or not isinstance(ocr_str, str): |
| 44 | return self.RESULT_N, ocr_str | 48 | return self.RESULT_NA, ocr_str |
| 45 | if kwargs.get('is_passport'): | 49 | if kwargs.get('is_passport'): |
| 46 | input_obj = re.search(r'[a-zA-Z]]!', input_str) | 50 | input_obj = re.search(r'[a-zA-Z]]!', input_str) |
| 47 | if input_obj: | 51 | if input_obj: |
| ... | @@ -61,8 +65,10 @@ class Comparison: | ... | @@ -61,8 +65,10 @@ class Comparison: |
| 61 | return self.build_res(input_s == ocr_s), ocr_str | 65 | return self.build_res(input_s == ocr_s), ocr_str |
| 62 | 66 | ||
| 63 | def date_compare(self, input_str, ocr_str, idx, **kwargs): | 67 | def date_compare(self, input_str, ocr_str, idx, **kwargs): |
| 68 | if ocr_str == '': | ||
| 69 | return self.RESULT_NA, None | ||
| 64 | if not isinstance(input_str, str) or not isinstance(ocr_str, str): | 70 | if not isinstance(input_str, str) or not isinstance(ocr_str, str): |
| 65 | return self.RESULT_N, ocr_str | 71 | return self.RESULT_NA, ocr_str |
| 66 | if kwargs.get('long', False) and '长期' in ocr_str: | 72 | if kwargs.get('long', False) and '长期' in ocr_str: |
| 67 | return self.RESULT_Y, '2099-12-31' | 73 | return self.RESULT_Y, '2099-12-31' |
| 68 | if kwargs.get('ocr_split', False): | 74 | if kwargs.get('ocr_split', False): |
| ... | @@ -85,7 +91,12 @@ class Comparison: | ... | @@ -85,7 +91,12 @@ class Comparison: |
| 85 | 91 | ||
| 86 | def rmb_compare(self, input_str, ocr_str, idx, **kwargs): | 92 | def rmb_compare(self, input_str, ocr_str, idx, **kwargs): |
| 87 | if not isinstance(input_str, str) or not isinstance(ocr_str, str): | 93 | if not isinstance(input_str, str) or not isinstance(ocr_str, str): |
| 88 | return self.RESULT_N, None | 94 | return self.RESULT_NA, None |
| 95 | if ocr_str == '': | ||
| 96 | if input_str == '0.0': | ||
| 97 | return self.RESULT_Y, input_str | ||
| 98 | else: | ||
| 99 | return self.RESULT_N, '0.0' | ||
| 89 | try: | 100 | try: |
| 90 | input_rmb_upper = to_rmb_upper(float(input_str)) | 101 | input_rmb_upper = to_rmb_upper(float(input_str)) |
| 91 | res = self.build_res(input_rmb_upper == ocr_str) | 102 | res = self.build_res(input_rmb_upper == ocr_str) |
| ... | @@ -98,8 +109,10 @@ class Comparison: | ... | @@ -98,8 +109,10 @@ class Comparison: |
| 98 | return res, None | 109 | return res, None |
| 99 | 110 | ||
| 100 | def type_compare(self, input_str, ocr_str, idx, **kwargs): | 111 | def type_compare(self, input_str, ocr_str, idx, **kwargs): |
| 112 | if ocr_str == '': | ||
| 113 | return self.RESULT_NA, None | ||
| 101 | if not isinstance(input_str, str) or not isinstance(ocr_str, str): | 114 | if not isinstance(input_str, str) or not isinstance(ocr_str, str): |
| 102 | return self.RESULT_N, ocr_str | 115 | return self.RESULT_NA, ocr_str |
| 103 | for map_tuple in self.TYPE_MAPPING: | 116 | for map_tuple in self.TYPE_MAPPING: |
| 104 | if re.search(map_tuple[0], ocr_str) is not None: | 117 | if re.search(map_tuple[0], ocr_str) is not None: |
| 105 | compare_str = map_tuple[1] | 118 | compare_str = map_tuple[1] | ... | ... |
-
Please register or sign in to post a comment