49ae7448 by 周伟奇

fix dealername4

1 parent 41cd5169
...@@ -7,7 +7,7 @@ TARGET_FIELD_INDIVIDUALS = { ...@@ -7,7 +7,7 @@ TARGET_FIELD_INDIVIDUALS = {
7 'value': { 7 'value': {
8 '姓名': ('under', {'left_padding': 1, 'right_padding': 1, 'scope': 2}, ''), 8 '姓名': ('under', {'left_padding': 1, 'right_padding': 1, 'scope': 2}, ''),
9 '个人身份证件号码': ('under', {'left_padding': 0.5, 'right_padding': 0.5, 'scope': 2}, ''), 9 '个人身份证件号码': ('under', {'left_padding': 0.5, 'right_padding': 0.5, 'scope': 2}, ''),
10 '经销商名称': ('under', {'left_padding': 0.1, 'right_padding': 0.1, 'scope': 2}, '') 10 '经销商名称': ('under', {'left_padding': 0.1, 'right_padding': 0.5, 'scope': 2, 'append': True}, '')
11 }, 11 },
12 'signature': { 12 'signature': {
13 '签字': {'signature', } 13 '签字': {'signature', }
......
...@@ -92,7 +92,7 @@ class Retriever: ...@@ -92,7 +92,7 @@ class Retriever:
92 return value, coordinates 92 return value, coordinates
93 93
94 @staticmethod 94 @staticmethod
95 def value_under(go_res, key_coordinates, left_padding, right_padding, scope, value_type=None): 95 def value_under(go_res, key_coordinates, left_padding, right_padding, scope, value_type=None, append=False):
96 # 字段值查找方向:下方 96 # 字段值查找方向:下方
97 width = key_coordinates[2] - key_coordinates[0] 97 width = key_coordinates[2] - key_coordinates[0]
98 x_min = key_coordinates[0] - (width * left_padding) 98 x_min = key_coordinates[0] - (width * left_padding)
...@@ -102,18 +102,22 @@ class Retriever: ...@@ -102,18 +102,22 @@ class Retriever:
102 y_min = key_coordinates[-1] 102 y_min = key_coordinates[-1]
103 y_max = key_coordinates[-1] + (height * scope) 103 y_max = key_coordinates[-1] + (height * scope)
104 104
105 y_min_find = None 105 find_list = []
106 value = None
107 coordinates = None
108 for (x0, y0, _, _, x1, y1, _, _), text in go_res.values(): 106 for (x0, y0, _, _, x1, y1, _, _), text in go_res.values():
109 cent_x = x0 + ((x1 - x0)/2) 107 cent_x = x0 + ((x1 - x0)/2)
110 cent_y = y0 + ((y1 - y0)/2) 108 cent_y = y0 + ((y1 - y0)/2)
111 if x_min < cent_x < x_max and y_min < cent_y < y_max: 109 if x_min < cent_x < x_max and y_min < cent_y < y_max:
112 if y_min_find is None or y0 < y_min_find:
113 if len(text.strip()) > 0: 110 if len(text.strip()) > 0:
114 y_min_find = y0 111 find_list.append(cent_x, cent_y, x0, y0, x1, y1, text)
115 value = text 112 if len(find_list) == 0:
116 coordinates = (x0, y0, x1, y1) 113 return None, None
114 else:
115 find_list.sort(key=lambda x: (x[1], x[0]))
116 coordinates = find_list[0][2: 6]
117 if append:
118 value = ''.join([text for _, _, _, _, _, _, text in find_list])
119 else:
120 value = find_list[0][-1]
117 return value, coordinates 121 return value, coordinates
118 122
119 @staticmethod 123 @staticmethod
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!