Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
b10ff66a
authored
2023-06-07 17:48:36 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix new hil contract
1 parent
f2cd1c73
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
96 deletions
src/common/electronic_hil_contract/get_char_fsm.py
src/common/electronic_hil_contract/get_char_fsm.py
View file @
b10ff66
...
...
@@ -34,9 +34,9 @@ class Finder:
"承租人-证件号码"
:
self
.
item
,
"承租人-法定代表人或授权代表"
:
self
.
item
,
"共同承租人-姓名"
:
self
.
item
,
"共同承租人-证件号码"
:
self
.
item
,
"共同承租人-法定代表人或授权代表"
:
self
.
item
,
#
"共同承租人-姓名": self.item,
#
"共同承租人-证件号码": self.item,
#
"共同承租人-法定代表人或授权代表": self.item,
"保证人1-姓名"
:
self
.
item
,
"保证人1-证件号码"
:
self
.
item
,
...
...
@@ -66,8 +66,8 @@ class Finder:
"签字页-承租人姓名"
:
self
.
item
,
"签字页-承租人签章"
:
self
.
item
,
"签字页-共同承租人姓名"
:
self
.
item
,
"签字页-共同承租人签章"
:
self
.
item
,
#
"签字页-共同承租人姓名": self.item,
#
"签字页-共同承租人签章": self.item,
"签字页-保证人1姓名"
:
self
.
item
,
"签字页-保证人1签章"
:
self
.
item
,
...
...
@@ -773,7 +773,7 @@ class Finder:
words
=
text
.
split
(
':'
)[
-
1
]
if
len
(
words
)
==
0
:
need_bbox_find_keys_bbox
[
0
]
=
bbox
else
:
#
else:
name
[
'words'
]
=
words
name
[
'page'
]
=
page_num
name
[
'position'
]
=
bbox
...
...
@@ -784,7 +784,7 @@ class Finder:
words
=
text
.
split
(
':'
)[
-
1
]
if
len
(
words
)
==
0
:
need_bbox_find_keys_bbox
[
1
]
=
bbox
else
:
#
else:
id_num
[
'words'
]
=
words
id_num
[
'page'
]
=
page_num
id_num
[
'position'
]
=
bbox
...
...
@@ -793,7 +793,7 @@ class Finder:
words
=
text
.
split
(
':'
)[
-
1
]
if
len
(
words
)
==
0
:
need_bbox_find_keys_bbox
[
2
]
=
bbox
else
:
#
else:
representative
[
'words'
]
=
words
representative
[
'page'
]
=
page_num
representative
[
'position'
]
=
bbox
...
...
@@ -803,7 +803,7 @@ class Finder:
words
=
text
.
split
(
':'
)[
-
1
]
if
len
(
words
)
==
0
:
need_bbox_find_keys_bbox
[
1
]
=
bbox
else
:
#
else:
id_num
[
'words'
]
=
words
id_num
[
'page'
]
=
page_num
id_num
[
'position'
]
=
bbox
...
...
@@ -812,7 +812,7 @@ class Finder:
words
=
text
.
split
(
':'
)[
-
1
]
if
len
(
words
)
==
0
:
need_bbox_find_keys_bbox
[
2
]
=
bbox
else
:
#
else:
representative
[
'words'
]
=
words
representative
[
'page'
]
=
page_num
representative
[
'position'
]
=
bbox
...
...
@@ -822,7 +822,7 @@ class Finder:
words
=
text
.
split
(
':'
)[
-
1
]
if
len
(
words
)
==
0
:
need_bbox_find_keys_bbox
[
1
]
=
bbox
else
:
#
else:
id_num
[
'words'
]
=
words
id_num
[
'page'
]
=
page_num
id_num
[
'position'
]
=
bbox
...
...
@@ -831,7 +831,7 @@ class Finder:
words
=
text
.
split
(
':'
)[
-
1
]
if
len
(
words
)
==
0
:
need_bbox_find_keys_bbox
[
2
]
=
bbox
else
:
#
else:
representative
[
'words'
]
=
words
representative
[
'page'
]
=
page_num
representative
[
'position'
]
=
bbox
...
...
@@ -841,7 +841,7 @@ class Finder:
words
=
text
.
split
(
':'
)[
-
1
]
if
len
(
words
)
==
0
:
need_bbox_find_keys_bbox
[
1
]
=
bbox
else
:
#
else:
id_num
[
'words'
]
=
words
id_num
[
'page'
]
=
page_num
id_num
[
'position'
]
=
bbox
...
...
@@ -850,7 +850,7 @@ class Finder:
words
=
text
.
split
(
':'
)[
-
1
]
if
len
(
words
)
==
0
:
need_bbox_find_keys_bbox
[
2
]
=
bbox
else
:
#
else:
representative
[
'words'
]
=
words
representative
[
'page'
]
=
page_num
representative
[
'position'
]
=
bbox
...
...
@@ -1243,17 +1243,17 @@ class Finder:
self
.
init_result
[
'合同编号'
]
=
contract_no
# 粗略判断是否是 ‘车贷分离版本’ 的合同
is_cdfl
=
False
for
block
in
self
.
pdf_info
[
'0'
][
'blocks'
]:
if
block
[
'type'
]
!=
0
:
continue
for
line
in
block
[
'lines'
]:
for
span
in
line
[
'spans'
]:
bbox
,
text
=
span
[
'bbox'
],
span
[
'text'
]
if
'共同承租人:'
in
text
:
is_cdfl
=
True
if
is_cdfl
==
False
:
#
is_cdfl = False
#
for block in self.pdf_info['0']['blocks']:
#
if block['type'] != 0:
#
continue
#
for line in block['lines']:
#
for span in line['spans']:
#
bbox, text = span['bbox'], span['text']
#
if '共同承租人:' in text:
#
is_cdfl = True
#
if is_cdfl == False:
# 从第一页上取四个角色的姓名和证件号码
name
,
id_num
,
representative
=
self
.
get_role_info
(
role_key
=
'承租人:'
,
page_num
=
'0'
)
...
...
@@ -1268,52 +1268,52 @@ class Finder:
self
.
init_result
[
'保证人1-证件号码'
]
=
id_num
self
.
init_result
[
'保证人1-法定代表人或授权代表'
]
=
representative
# if条件判别 对应3_3版本
if
name
[
"words"
]
==
None
:
name
,
id_num
,
representative
=
self
.
get_role_info_3_3
(
role_key
=
'共同承租人:'
,
page_num
=
'0'
)
self
.
init_result
[
'共同承租人-姓名'
]
=
name
self
.
init_result
[
'共同承租人-证件号码'
]
=
id_num
self
.
init_result
[
'共同承租人-法定代表人或授权代表'
]
=
representative
#
if name["words"] == None:
#
name, id_num, representative = self.get_role_info_3_3(role_key='共同承租人:', page_num='0')
#
self.init_result['共同承租人-姓名'] = name
#
self.init_result['共同承租人-证件号码'] = id_num
#
self.init_result['共同承租人-法定代表人或授权代表'] = representative
name
,
id_num
,
representative
=
self
.
get_role_info
(
role_key
=
'保证人2:'
,
page_num
=
'0'
)
self
.
init_result
[
'保证人2-姓名'
]
=
name
self
.
init_result
[
'保证人2-证件号码'
]
=
id_num
self
.
init_result
[
'保证人2-法定代表人或授权代表'
]
=
representative
# if条件判别 对应3_3版本
if
name
[
"words"
]
==
None
:
name
,
id_num
,
representative
=
self
.
get_role_info_3_3
(
role_key
=
'保证人1:'
,
page_num
=
'0'
)
self
.
init_result
[
'保证人2-姓名'
]
=
name
self
.
init_result
[
'保证人2-证件号码'
]
=
id_num
self
.
init_result
[
'保证人2-法定代表人或授权代表'
]
=
representative
#
if name["words"] == None:
#
name, id_num, representative = self.get_role_info_3_3(role_key='保证人1:', page_num='0')
#
self.init_result['保证人2-姓名'] = name
#
self.init_result['保证人2-证件号码'] = id_num
#
self.init_result['保证人2-法定代表人或授权代表'] = representative
name
,
id_num
,
representative
=
self
.
get_role_info
(
role_key
=
'保证人3:'
,
page_num
=
'0'
)
self
.
init_result
[
'保证人3-姓名'
]
=
name
self
.
init_result
[
'保证人3-证件号码'
]
=
id_num
self
.
init_result
[
'保证人3-法定代表人或授权代表'
]
=
representative
if
name
[
"words"
]
==
None
:
name
,
id_num
,
representative
=
self
.
get_role_info_3_3
(
role_key
=
'保证人2:'
,
page_num
=
'0'
)
self
.
init_result
[
'保证人3-姓名'
]
=
name
self
.
init_result
[
'保证人3-证件号码'
]
=
id_num
self
.
init_result
[
'保证人3-法定代表人或授权代表'
]
=
representative
else
:
name
,
id_num
,
representative
=
self
.
get_role_info_3_3
(
role_key
=
'承租人一:'
,
page_num
=
'0'
)
self
.
init_result
[
'承租人-姓名'
]
=
name
self
.
init_result
[
'承租人-证件号码'
]
=
id_num
self
.
init_result
[
'承租人-法定代表人或授权代表'
]
=
representative
name
,
id_num
,
representative
=
self
.
get_role_info_3_3
(
role_key
=
'共同承租人:'
,
page_num
=
'0'
)
self
.
init_result
[
'共同承租人-姓名'
]
=
name
self
.
init_result
[
'共同承租人-证件号码'
]
=
id_num
self
.
init_result
[
'共同承租人-法定代表人或授权代表'
]
=
representative
name
,
id_num
,
representative
=
self
.
get_role_info_3_3
(
role_key
=
'保证人1:'
,
page_num
=
'0'
)
self
.
init_result
[
'保证人1-姓名'
]
=
name
self
.
init_result
[
'保证人1-证件号码'
]
=
id_num
self
.
init_result
[
'保证人1-法定代表人或授权代表'
]
=
representative
name
,
id_num
,
representative
=
self
.
get_role_info_3_3
(
role_key
=
'保证人2:'
,
page_num
=
'0'
)
self
.
init_result
[
'保证人2-姓名'
]
=
name
self
.
init_result
[
'保证人2-证件号码'
]
=
id_num
self
.
init_result
[
'保证人2-法定代表人或授权代表'
]
=
representative
#
if name["words"] == None:
#
name, id_num, representative = self.get_role_info_3_3(role_key='保证人2:', page_num='0')
#
self.init_result['保证人3-姓名'] = name
#
self.init_result['保证人3-证件号码'] = id_num
#
self.init_result['保证人3-法定代表人或授权代表'] = representative
#
else:
#
name, id_num, representative = self.get_role_info_3_3(role_key='承租人一:', page_num='0')
#
self.init_result['承租人-姓名'] = name
#
self.init_result['承租人-证件号码'] = id_num
#
self.init_result['承租人-法定代表人或授权代表'] = representative
#
name, id_num, representative = self.get_role_info_3_3(role_key='共同承租人:', page_num='0')
#
self.init_result['共同承租人-姓名'] = name
#
self.init_result['共同承租人-证件号码'] = id_num
#
self.init_result['共同承租人-法定代表人或授权代表'] = representative
#
name, id_num, representative = self.get_role_info_3_3(role_key='保证人1:', page_num='0')
#
self.init_result['保证人1-姓名'] = name
#
self.init_result['保证人1-证件号码'] = id_num
#
self.init_result['保证人1-法定代表人或授权代表'] = representative
#
name, id_num, representative = self.get_role_info_3_3(role_key='保证人2:', page_num='0')
#
self.init_result['保证人2-姓名'] = name
#
self.init_result['保证人2-证件号码'] = id_num
#
self.init_result['保证人2-法定代表人或授权代表'] = representative
# 在所有页面中找正文中(第二部分 融资租赁主要条款及付款计划)的那个编号,因为存在换行的情况所以暂时不带位置输出
contract_no
=
self
.
get_contract_no_one
()
...
...
@@ -1361,7 +1361,7 @@ class Finder:
# 找签字页上的系列信息
# 承租人姓名、签章
if
is_cdfl
==
False
:
#
if is_cdfl == False:
name
=
self
.
get_key_value
(
key
=
'承租人姓名:'
)
electronic_signature
=
self
.
get_electronic_signature
(
top
=
'承租人姓名:'
,
bottom
=
'保证人1姓名:'
,
t_pno
=
'5'
)
...
...
@@ -1377,53 +1377,53 @@ class Finder:
self
.
init_result
[
'签字页-保证人1姓名'
]
=
name
self
.
init_result
[
'签字页-保证人1签章'
]
=
electronic_signature
# 这里用的是 name["words"] == ""
if
name
[
"words"
]
==
""
:
name
=
self
.
get_key_value
(
key
=
'共同承租人名称:'
)
electronic_signature
=
self
.
get_electronic_signature
(
top
=
'共同承租人名称:'
,
bottom
=
'保证人1姓名:'
,
t_pno
=
'5'
)
self
.
init_result
[
'签字页-共同承租人姓名'
]
=
name
self
.
init_result
[
'签字页-共同承租人签章'
]
=
electronic_signature
#
if name["words"] == "":
#
name = self.get_key_value(key='共同承租人名称:')
#
electronic_signature = self.get_electronic_signature(top='共同承租人名称:', bottom='保证人1姓名:', t_pno='5')
#
self.init_result['签字页-共同承租人姓名'] = name
#
self.init_result['签字页-共同承租人签章'] = electronic_signature
# 保证人2姓名、签章
name
=
self
.
get_key_value
(
key
=
'保证人2姓名:'
)
electronic_signature
=
self
.
get_electronic_signature
(
top
=
'保证人2姓名:'
,
bottom
=
'保证人3姓名:'
,
t_pno
=
'5'
)
self
.
init_result
[
'签字页-保证人2姓名'
]
=
name
self
.
init_result
[
'签字页-保证人2签章'
]
=
electronic_signature
# if判断条件对应3_3版本
if
name
[
"words"
]
==
""
:
name
=
self
.
get_key_value
(
key
=
'保证人1姓名:'
)
electronic_signature
=
self
.
get_electronic_signature
(
top
=
'保证人1姓名:'
,
bottom
=
'保证人2姓名:'
,
t_pno
=
'5'
)
self
.
init_result
[
'签字页-保证人1姓名'
]
=
name
self
.
init_result
[
'签字页-保证人1签章'
]
=
electronic_signature
#
if name["words"] == "":
#
name = self.get_key_value(key='保证人1姓名:')
#
electronic_signature = self.get_electronic_signature(top='保证人1姓名:', bottom='保证人2姓名:', t_pno='5')
#
self.init_result['签字页-保证人1姓名'] = name
#
self.init_result['签字页-保证人1签章'] = electronic_signature
# 保证人3姓名、签章
name
=
self
.
get_key_value
(
key
=
'保证人3姓名:'
)
electronic_signature
=
self
.
get_electronic_signature
(
top
=
'保证人3姓名:'
,
bottom
=
'日期:'
,
t_pno
=
'5'
)
self
.
init_result
[
'签字页-保证人3姓名'
]
=
name
self
.
init_result
[
'签字页-保证人3签章'
]
=
electronic_signature
# if判断条件对应3_3版本
if
name
[
"words"
]
==
None
:
name
=
self
.
get_key_value
(
key
=
'保证人2姓名:'
)
electronic_signature
=
self
.
get_electronic_signature
(
top
=
'保证人2姓名:'
,
bottom
=
'日期:'
,
t_pno
=
'5'
)
self
.
init_result
[
'签字页-保证人2姓名'
]
=
name
self
.
init_result
[
'签字页-保证人2签章'
]
=
electronic_signature
else
:
name
=
self
.
get_key_value
(
key
=
'承租人一姓名:'
)
electronic_signature
=
self
.
get_electronic_signature
(
top
=
'承租人一姓名:'
,
bottom
=
'共同承租人名称:'
,
t_pno
=
'5'
)
self
.
init_result
[
'签字页-承租人姓名'
]
=
name
self
.
init_result
[
'签字页-承租人签章'
]
=
electronic_signature
name
=
self
.
get_key_value
(
key
=
'共同承租人名称:'
)
electronic_signature
=
self
.
get_electronic_signature
(
top
=
'共同承租人名称:'
,
bottom
=
'保证人1姓名:'
,
t_pno
=
'5'
)
self
.
init_result
[
'签字页-共同承租人姓名'
]
=
name
self
.
init_result
[
'签字页-共同承租人签章'
]
=
electronic_signature
name
=
self
.
get_key_value
(
key
=
'保证人1姓名:'
)
electronic_signature
=
self
.
get_electronic_signature
(
top
=
'保证人1姓名:'
,
bottom
=
'保证人2姓名:'
,
t_pno
=
'5'
)
self
.
init_result
[
'签字页-保证人1姓名'
]
=
name
self
.
init_result
[
'签字页-保证人1签章'
]
=
electronic_signature
name
=
self
.
get_key_value
(
key
=
'保证人2姓名:'
)
electronic_signature
=
self
.
get_electronic_signature
(
top
=
'保证人2姓名:'
,
bottom
=
'保证人3姓名:'
,
t_pno
=
'5'
)
self
.
init_result
[
'签字页-保证人2姓名'
]
=
name
self
.
init_result
[
'签字页-保证人2签章'
]
=
electronic_signature
#
if name["words"] == None:
#
name = self.get_key_value(key='保证人2姓名:')
#
electronic_signature = self.get_electronic_signature(top='保证人2姓名:', bottom='日期:', t_pno='5')
#
self.init_result['签字页-保证人2姓名'] = name
#
self.init_result['签字页-保证人2签章'] = electronic_signature
#
else:
#
name = self.get_key_value(key='承租人一姓名:')
#
electronic_signature = self.get_electronic_signature(top='承租人一姓名:', bottom='共同承租人名称:', t_pno='5')
#
self.init_result['签字页-承租人姓名'] = name
#
self.init_result['签字页-承租人签章'] = electronic_signature
#
name = self.get_key_value(key='共同承租人名称:')
#
electronic_signature = self.get_electronic_signature(top='共同承租人名称:', bottom='保证人1姓名:', t_pno='5')
#
self.init_result['签字页-共同承租人姓名'] = name
#
self.init_result['签字页-共同承租人签章'] = electronic_signature
#
name = self.get_key_value(key='保证人1姓名:')
#
electronic_signature = self.get_electronic_signature(top='保证人1姓名:', bottom='保证人2姓名:', t_pno='5')
#
self.init_result['签字页-保证人1姓名'] = name
#
self.init_result['签字页-保证人1签章'] = electronic_signature
#
name = self.get_key_value(key='保证人2姓名:')
#
electronic_signature = self.get_electronic_signature(top='保证人2姓名:', bottom='保证人3姓名:', t_pno='5')
#
self.init_result['签字页-保证人2姓名'] = name
#
self.init_result['签字页-保证人2签章'] = electronic_signature
return
self
.
init_result
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment