49ae7448 by 周伟奇

fix dealername4

1 parent 41cd5169
......@@ -7,7 +7,7 @@ TARGET_FIELD_INDIVIDUALS = {
'value': {
'姓名': ('under', {'left_padding': 1, 'right_padding': 1, 'scope': 2}, ''),
'个人身份证件号码': ('under', {'left_padding': 0.5, 'right_padding': 0.5, 'scope': 2}, ''),
'经销商名称': ('under', {'left_padding': 0.1, 'right_padding': 0.1, 'scope': 2}, '')
'经销商名称': ('under', {'left_padding': 0.1, 'right_padding': 0.5, 'scope': 2, 'append': True}, '')
},
'signature': {
'签字': {'signature', }
......
......@@ -92,7 +92,7 @@ class Retriever:
return value, coordinates
@staticmethod
def value_under(go_res, key_coordinates, left_padding, right_padding, scope, value_type=None):
def value_under(go_res, key_coordinates, left_padding, right_padding, scope, value_type=None, append=False):
# 字段值查找方向:下方
width = key_coordinates[2] - key_coordinates[0]
x_min = key_coordinates[0] - (width * left_padding)
......@@ -102,18 +102,22 @@ class Retriever:
y_min = key_coordinates[-1]
y_max = key_coordinates[-1] + (height * scope)
y_min_find = None
value = None
coordinates = None
find_list = []
for (x0, y0, _, _, x1, y1, _, _), text in go_res.values():
cent_x = x0 + ((x1 - x0)/2)
cent_y = y0 + ((y1 - y0)/2)
if x_min < cent_x < x_max and y_min < cent_y < y_max:
if y_min_find is None or y0 < y_min_find:
if len(text.strip()) > 0:
y_min_find = y0
value = text
coordinates = (x0, y0, x1, y1)
find_list.append(cent_x, cent_y, x0, y0, x1, y1, text)
if len(find_list) == 0:
return None, None
else:
find_list.sort(key=lambda x: (x[1], x[0]))
coordinates = find_list[0][2: 6]
if append:
value = ''.join([text for _, _, _, _, _, _, text in find_list])
else:
value = find_list[0][-1]
return value, coordinates
@staticmethod
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!