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
7f868e1c
authored
2022-05-18 16:32:29 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
contract cdfl
1 parent
4d0b881c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
5 deletions
src/common/electronic_afc_contract/get_char.py
src/common/electronic_hil_contract/get_char.py
src/common/electronic_afc_contract/get_char.py
View file @
7f868e1
...
...
@@ -774,6 +774,9 @@ class Finder:
# 这是为了同时兼容 8.1 版本
if
borrower_name
[
'words'
]
==
None
:
borrower_name
,
borrower_id
=
self
.
get_somebody
(
top
=
'借款人及抵押人:'
,
bottom
=
'共同借款人及共同抵押人:'
)
# 这是为了兼容车贷分离版本
if
borrower_name
[
'words'
]
==
None
:
borrower_name
,
borrower_id
=
self
.
get_somebody
(
top
=
'借款人:'
,
bottom
=
'共同借款人及抵押人:'
)
self
.
init_result
[
'page_2'
][
'借款人及抵押人'
][
'name'
]
=
borrower_name
self
.
init_result
[
'page_2'
][
'借款人及抵押人'
][
'id'
]
=
borrower_id
# 找共同借款人及共同抵押人
...
...
@@ -852,10 +855,16 @@ class Finder:
self
.
init_result
[
'page_7'
][
'合同编号'
]
=
contract_no
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'6'
,
top
=
'合同编号'
,
bottom
=
'共同借款人'
)
if
signature_name
[
'words'
]
==
None
:
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'6'
,
top
=
'合同编号'
,
bottom
=
'共同借款人(抵押人)'
)
self
.
init_result
[
'page_7'
][
'主借人签字'
][
'签字'
]
=
signature_name
self
.
init_result
[
'page_7'
][
'主借人签字'
][
'日期'
]
=
signature_date
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'6'
,
top
=
'共同借款人'
,
bottom
=
'保证人1'
)
if
signature_name
[
'words'
]
==
None
:
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'6'
,
top
=
'共同借款人(抵押人)'
,
bottom
=
'保证人1'
)
self
.
init_result
[
'page_7'
][
'共借人签字'
][
'签字'
]
=
signature_name
self
.
init_result
[
'page_7'
][
'共借人签字'
][
'日期'
]
=
signature_date
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'6'
,
...
...
@@ -881,10 +890,16 @@ class Finder:
self
.
init_result
[
'page_8'
][
'合同编号'
]
=
contract_no
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'7'
,
top
=
'合同编号'
,
bottom
=
'共同借款人'
)
if
signature_name
[
'words'
]
==
None
:
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'7'
,
top
=
'合同编号'
,
bottom
=
'共同借款人(抵押人)'
)
self
.
init_result
[
'page_8'
][
'主借人签字'
][
'签字'
]
=
signature_name
self
.
init_result
[
'page_8'
][
'主借人签字'
][
'日期'
]
=
signature_date
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'7'
,
top
=
'共同借款人'
,
bottom
=
'保证人1'
)
if
signature_name
[
'words'
]
==
None
:
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'7'
,
top
=
'共同借款人(抵押人)'
,
bottom
=
'保证人1'
)
self
.
init_result
[
'page_8'
][
'共借人签字'
][
'签字'
]
=
signature_name
self
.
init_result
[
'page_8'
][
'共借人签字'
][
'日期'
]
=
signature_date
signature_name
,
signature_date
=
self
.
get_last_page_signature
(
page_num
=
'7'
,
...
...
src/common/electronic_hil_contract/get_char.py
View file @
7f868e1
...
...
@@ -847,7 +847,7 @@ class Finder:
for
i
in
range
(
5
):
for
span
in
ocr_results
:
iou
=
caculate_iou
(
anchor
,
span
[
0
])
if
iou
>
0
and
span
[
1
]
.
strip
()
!=
'所购'
:
if
iou
>
0
.01
and
span
[
1
]
.
strip
()
!=
'所购'
:
x
=
get_table_info
(
span
[
0
],
ocr_results
[
key_gmjg
][
0
],
ocr_results
)
y
=
get_table_info
(
span
[
0
],
ocr_results
[
key_sjrzje
][
0
],
ocr_results
)
line
=
[
span
[
1
]
.
replace
(
'
\u3000
'
,
' '
),
x
,
y
]
...
...
@@ -1088,6 +1088,17 @@ class Finder:
# 取 Page 1 上的合同编号
contract_no
=
self
.
get_contract_no
(
page_num
=
'0'
)
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
:
# 从第一页上取四个角色的姓名和证件号码
name
,
id_num
,
representative
=
self
.
get_role_info
(
role_key
=
'承租人:'
,
page_num
=
'0'
)
if
name
[
"words"
]
==
None
:
...
...
@@ -1124,6 +1135,23 @@ class Finder:
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
()
self
.
init_result
[
'合同编号(正文)'
]
=
contract_no
...
...
@@ -1157,6 +1185,7 @@ class Finder:
self
.
init_result
[
'银行账户-开户行'
]
=
bank
# 找签字页上的系列信息
# 承租人姓名、签章
if
is_cdfl
==
False
:
name
=
self
.
get_key_value
(
key
=
'承租人姓名:'
)
electronic_signature
=
self
.
get_electronic_signature
(
top
=
'承租人姓名:'
,
bottom
=
'保证人1姓名:'
)
if
name
[
"words"
]
==
None
:
...
...
@@ -1197,11 +1226,24 @@ class Finder:
electronic_signature
=
self
.
get_electronic_signature
(
top
=
'保证人2姓名:'
,
bottom
=
'日期:'
)
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
=
'共同承租人名称:'
)
self
.
init_result
[
'签字页-承租人姓名'
]
=
name
self
.
init_result
[
'签字页-承租人签章'
]
=
electronic_signature
name
=
self
.
get_key_value
(
key
=
'共同承租人名称:'
)
electronic_signature
=
self
.
get_electronic_signature
(
top
=
'共同承租人名称:'
,
bottom
=
'保证人1姓名:'
)
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姓名:'
)
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姓名:'
)
self
.
init_result
[
'签字页-保证人2姓名'
]
=
name
self
.
init_result
[
'签字页-保证人2签章'
]
=
electronic_signature
return
self
.
init_result
# results['is_shhz_contract'] = True
# results['pdf_info'] = self.init_result
# return results
def
get_info_1
(
self
):
if
len
(
self
.
pdf_info
)
>
0
:
...
...
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