Explorar o código

update 生产厂家比对

zeke-chin %!s(int64=2) %!d(string=hai) anos
pai
achega
7e80d1b935
Modificáronse 1 ficheiros con 7 adicións e 3 borrados
  1. 7 3
      YQ_OCR/to_md/convert_MD.py

+ 7 - 3
YQ_OCR/to_md/convert_MD.py

@@ -1,3 +1,4 @@
+import copy
 import re
 from itertools import chain
 from pathlib import Path
@@ -12,7 +13,7 @@ from YQ_OCR.config import keyDict
 
 url = 'http://192.168.199.107:18087'
 url_path = '/ocr_system/identify'
-imgs_path = '/Users/zeke/work/sx/OCR/image_data/样签图片'
+imgs_path = '/Users/zeke/work/sx/OCR/HROCR/to_md/YQ_OCR/img'
 
 
 # 1. xlsx -> 正确json文件(写入厂家信息)
@@ -57,16 +58,19 @@ def _parse_result(r):  # sourcery skip: dict-comprehension
 # 比较两个json文件 并在md文件中写入对比结果
 def evaluate_one(xlsx_dict, res_dict):
     true_num = 0
+    xlsx_dict_no_space = copy.deepcopy(xlsx_dict)
+    for index, text in enumerate(xlsx_dict_no_space):
+        xlsx_dict_no_space[index] = text.replace(' ', '')
     for key_yes in res_dict:
         if type(res_dict[key_yes]) is str:
-            if Levenshtein_Distance(res_dict[key_yes], xlsx_dict[key_yes]) == 0:
+            if Levenshtein_Distance(res_dict[key_yes], xlsx_dict_no_space[key_yes]) == 0:
                 table_result.extend([key_yes, xlsx_dict[key_yes], res_dict[key_yes], '✅'])
                 true_num += 1
             else:
                 table_result.extend([key_yes, xlsx_dict[key_yes], res_dict[key_yes], '❌'])
 
     key_no_dict = {}
-    for key_no_xlsx in xlsx_dict['noKeyList']:
+    for key_no_xlsx in xlsx_dict_no_space['noKeyList']:
         key_no_dict[key_no_xlsx] = []
         for key_no_res in res_dict['noKeyList']:
             key_no_dict[key_no_xlsx].append((Levenshtein_Distance(key_no_xlsx, key_no_res), key_no_res))