|
@@ -12,23 +12,27 @@ def get_key_fist_line(res_line_list, key):
|
|
|
|
|
|
# 需改动
|
|
|
if key == '经营范围':
|
|
|
+ print(res_line_list[-1][0])
|
|
|
key_str = res_line_list[-1][0].split('市')[0].split('住所')[0].split('经营范围')[-1]
|
|
|
+ print('key_str', key_str)
|
|
|
else:
|
|
|
key_str = res_line_list[-1][0].split(key)[-1]
|
|
|
|
|
|
# title
|
|
|
key_title = False
|
|
|
key_title_list = []
|
|
|
+ # print(res_line_list[:-1])
|
|
|
for r in res_line_list[:-1]:
|
|
|
+ # print(r.txt)
|
|
|
if string_similar(r.txt, key) > 0.7:
|
|
|
if len(r.txt) > len(key_str) + 2:
|
|
|
- box = r[0]
|
|
|
+ box = r.box
|
|
|
raw_w = box[1][0] - box[0][0]
|
|
|
ratio = len(key) / len(r.txt)
|
|
|
title_w = raw_w * ratio
|
|
|
box[1][0] = box[0][0] + title_w
|
|
|
box[2][0] = box[0][0] + title_w
|
|
|
- key_title = OcrResult(np.array(box), key, r[1][1])
|
|
|
+ key_title = OcrResult(np.array(box), key, r.txt)
|
|
|
break
|
|
|
else:
|
|
|
key_title = r
|
|
@@ -56,7 +60,6 @@ def get_key_fist_line(res_line_list, key):
|
|
|
|
|
|
|
|
|
def get_key_other_or(res_raw_list, key_heard: OcrResult, key_title):
|
|
|
-
|
|
|
def h_range():
|
|
|
h_list = []
|
|
|
for key in keys_list:
|
|
@@ -81,7 +84,6 @@ def get_key_other_or(res_raw_list, key_heard: OcrResult, key_title):
|
|
|
return True
|
|
|
return False
|
|
|
|
|
|
-
|
|
|
def merge_box(boxes: List[OcrResult]):
|
|
|
txt = boxes[0].txt
|
|
|
box = boxes[0].box
|
|
@@ -120,12 +122,14 @@ def get_key_other_or(res_raw_list, key_heard: OcrResult, key_title):
|
|
|
|
|
|
def parser_xy(res_line, res_raw, key):
|
|
|
# 在 res_line 中找到 key 对应的坐标
|
|
|
+ print('res_line', res_line)
|
|
|
key_row = []
|
|
|
for row in res_line:
|
|
|
+ print(row[-1])
|
|
|
if key in row[-1][0]:
|
|
|
key_row = row
|
|
|
break
|
|
|
-
|
|
|
+ print(key_row)
|
|
|
if not bool(key_row): return
|
|
|
key_heard, key_title = get_key_fist_line(key_row, key)
|
|
|
return get_key_other_or(res_raw, key_heard, key_title)
|