01314b0c by 周伟奇

add se oct

1 parent 07c844aa
...@@ -2377,9 +2377,10 @@ def se_compare_license_id(license_en, id_res_list, field_list): ...@@ -2377,9 +2377,10 @@ def se_compare_license_id(license_en, id_res_list, field_list):
2377 result_field_list = [] 2377 result_field_list = []
2378 section_img_info = dict() 2378 section_img_info = dict()
2379 field_img_path_dict = dict() 2379 field_img_path_dict = dict()
2380 field_last_idx = len(field_list) - 1
2380 2381
2381 # ocr_res_str = ocr_res_dict.get(ocr_field) 2382 # ocr_res_str = ocr_res_dict.get(ocr_field)
2382 for ocr_res_str in id_res_list: 2383 for ca_or_se_idx, ocr_res_str in enumerate(id_res_list):
2383 if is_find: 2384 if is_find:
2384 break 2385 break
2385 2386
...@@ -2428,16 +2429,11 @@ def se_compare_license_id(license_en, id_res_list, field_list): ...@@ -2428,16 +2429,11 @@ def se_compare_license_id(license_en, id_res_list, field_list):
2428 result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) 2429 result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2])
2429 no_key = False 2430 no_key = False
2430 2431
2431 if idx == 0 and result == consts.RESULT_N and length > 1: 2432 if idx == 0 and result == consts.RESULT_N:
2432 break 2433 if ca_or_se_idx == 0:
2433 2434 break
2434 is_find = True 2435 elif length > 1:
2435 section_img_info[consts.SECTION_IMG_PATH_KEY] = ocr_res_list[res_idx].get(consts.SECTION_IMG_PATH_KEY, '') 2436 break
2436 section_img_info[consts.ALL_POSITION_KEY] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY, {})
2437 if special_expiry_date:
2438 section_img_info[consts.SECTION_IMG_PATH_KEY_2] = ocr_res_list[res_idx].get(
2439 consts.SECTION_IMG_PATH_KEY_2, '')
2440 section_img_info[consts.ALL_POSITION_KEY_2] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY_2, {})
2441 2437
2442 # 过期期限特殊处理 2438 # 过期期限特殊处理
2443 if special_expiry_date and name == 'idExpiryDate' and result == consts.RESULT_N: 2439 if special_expiry_date and name == 'idExpiryDate' and result == consts.RESULT_N:
...@@ -2448,14 +2444,17 @@ def se_compare_license_id(license_en, id_res_list, field_list): ...@@ -2448,14 +2444,17 @@ def se_compare_license_id(license_en, id_res_list, field_list):
2448 img_path = empty_str 2444 img_path = empty_str
2449 else: 2445 else:
2450 for expiry_date, (date_img_path, date_res_idx) in expiry_dates.items(): 2446 for expiry_date, (date_img_path, date_res_idx) in expiry_dates.items():
2451 expiry_date_res = getattr(cp, compare_logic[name][1])(value, expiry_date, **compare_logic[name][2]) 2447 expiry_date_res = getattr(cp, compare_logic[name][1])(value, expiry_date,
2448 **compare_logic[name][2])
2452 if expiry_date_res == consts.RESULT_N: 2449 if expiry_date_res == consts.RESULT_N:
2453 ocr_str = expiry_date 2450 ocr_str = expiry_date
2454 img_path = date_img_path 2451 img_path = date_img_path
2455 special_expiry_date_slice = True 2452 special_expiry_date_slice = True
2456 section_img_info[consts.SECTION_IMG_PATH_KEY_2] = ocr_res_list[date_res_idx].get( 2453 section_img_info[consts.SECTION_IMG_PATH_KEY_2] = ocr_res_list[
2454 date_res_idx].get(
2457 consts.SECTION_IMG_PATH_KEY_2, '') 2455 consts.SECTION_IMG_PATH_KEY_2, '')
2458 section_img_info[consts.ALL_POSITION_KEY_2] = ocr_res_list[date_res_idx].get( 2456 section_img_info[consts.ALL_POSITION_KEY_2] = ocr_res_list[
2457 date_res_idx].get(
2459 consts.ALL_POSITION_KEY_2, {}) 2458 consts.ALL_POSITION_KEY_2, {})
2460 break 2459 break
2461 else: 2460 else:
...@@ -2466,7 +2465,27 @@ def se_compare_license_id(license_en, id_res_list, field_list): ...@@ -2466,7 +2465,27 @@ def se_compare_license_id(license_en, id_res_list, field_list):
2466 img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY_2, '') 2465 img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY_2, '')
2467 special_expiry_date_slice = True 2466 special_expiry_date_slice = True
2468 else: 2467 else:
2469 img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str 2468 img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY,
2469 '') if result == consts.RESULT_N else empty_str
2470
2471 if ca_or_se_idx == 0 and result == consts.RESULT_N:
2472 special_expiry_date_slice = False
2473 section_img_info.pop(consts.SECTION_IMG_PATH_KEY_2, None)
2474 section_img_info.pop(consts.ALL_POSITION_KEY_2, None)
2475 break
2476
2477 if ca_or_se_idx == 1:
2478 is_find = True
2479 elif idx == field_last_idx:
2480 is_find = True
2481
2482 section_img_info[consts.SECTION_IMG_PATH_KEY] = ocr_res_list[res_idx].get(consts.SECTION_IMG_PATH_KEY, '')
2483 section_img_info[consts.ALL_POSITION_KEY] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY, {})
2484 if special_expiry_date and consts.SECTION_IMG_PATH_KEY_2 not in section_img_info:
2485 section_img_info[consts.SECTION_IMG_PATH_KEY_2] = ocr_res_list[res_idx].get(
2486 consts.SECTION_IMG_PATH_KEY_2, '')
2487 section_img_info[consts.ALL_POSITION_KEY_2] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY_2, {})
2488
2470 if isinstance(value, list): 2489 if isinstance(value, list):
2471 value = json.dumps(value, ensure_ascii=False) 2490 value = json.dumps(value, ensure_ascii=False)
2472 error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value 2491 error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value
...@@ -3148,8 +3167,8 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True ...@@ -3148,8 +3167,8 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
3148 id_res_list = [] 3167 id_res_list = []
3149 for field_name in consts.CA_ADD_COMPARE_FIELDS: 3168 for field_name in consts.CA_ADD_COMPARE_FIELDS:
3150 if field_name == consts.IC_OCR_FIELD: 3169 if field_name == consts.IC_OCR_FIELD:
3151 id_res_list.append(ocr_res_dict.get(field_name))
3152 id_res_list.append(ca_ocr_res_dict.get(field_name) if isinstance(ca_ocr_res_dict, dict) else None) 3170 id_res_list.append(ca_ocr_res_dict.get(field_name) if isinstance(ca_ocr_res_dict, dict) else None)
3171 id_res_list.append(ocr_res_dict.get(field_name))
3153 3172
3154 if isinstance(ca_ocr_res_dict, dict) and isinstance(ca_ocr_res_dict.get(field_name), str): 3173 if isinstance(ca_ocr_res_dict, dict) and isinstance(ca_ocr_res_dict.get(field_name), str):
3155 tmp_ca_result = json.loads(ca_ocr_res_dict.get(field_name)) 3174 tmp_ca_result = json.loads(ca_ocr_res_dict.get(field_name))
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!