fd556337 by 周伟奇

add contract 8.5

1 parent 2dc31fab
......@@ -2970,6 +2970,8 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first()
if auto_obj is not None:
auto_result = se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj)
else:
auto_result = None
full_result = se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms, auto_result)
......
......@@ -6,28 +6,35 @@
# @Description :
from .get_char import Finder
import numpy as np
def predict(pdf_info):
ocr_results = {}
for pno in pdf_info:
ocr_results[pno] = {}
ocr_result = []
for key, block in enumerate(pdf_info[pno]['blocks']):
if block['type'] != 0:
continue
for line in block['lines']:
for span in line['spans']:
bbox, text = span['bbox'], span['text']
if len(text) == 0:
continue
# print(text)
xmin, ymin, xmax, ymax = bbox
polygon = [xmin, ymin, xmax, ymin, xmax, ymax, xmin, ymax]
polygon = np.array(polygon, dtype=np.int32).tolist()
text = text.replace(":", ":").replace(" ", "")
ocr_results[pno][key] = [polygon, text]
ocr_result.append([polygon, text])
ocr_result = sorted(ocr_result, key=lambda x: x[0][1], reverse=False) # 按 y0 从小到大排
keys = list(range(len(ocr_result)))
ocr_result = dict(zip(keys, ocr_result))
ocr_results[pno] = ocr_result
# 输入是整个 PDF 中的信息
f = Finder(pdf_info, ocr_results=ocr_results)
results = f.get_info()
return results
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!