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
c113f2a4
authored
2022-01-24 11:04:09 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add ltgt bzll
1 parent
12319785
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
28 deletions
src/apps/doc/consts.py
src/common/electronic_afc_contract/get_char.py
src/apps/doc/consts.py
View file @
c113f2a
...
...
@@ -1434,6 +1434,7 @@ ASP_KEY = 'is_asp'
AFC_CON_MAP_LTGT
=
{
'合同编号'
:
(
2
,
2
,
'合同编号'
,
None
),
'标准利率'
:
(
2
,
2
,
'标准利率'
,
None
),
'借款人姓名'
:
(
2
,
2
,
'借款人及抵押人'
,
'name'
),
'共借人姓名'
:
(
2
,
2
,
'共同借款人及共同抵押人'
,
'name'
),
'保证人姓名1'
:
(
2
,
2
,
'保证人1'
,
'name'
),
...
...
@@ -1446,6 +1447,7 @@ AFC_CON_FIELD_ORDER_LTGT = (
(
'共借人姓名'
,
'共借人姓名'
),
(
'保证人姓名1'
,
'保证人姓名1'
),
(
'保证人姓名2'
,
'保证人姓名2'
),
(
'标准利率'
,
'标准利率'
),
)
SE_AFC_CON_MAP
=
{
...
...
src/common/electronic_afc_contract/get_char.py
View file @
c113f2a
...
...
@@ -55,6 +55,7 @@ class Finder:
"附加产品融资贷款本金总金额"
:
self
.
item
,
},
"贷款期限"
:
self
.
item
,
"标准利率"
:
self
.
item
,
"还款账户"
:
{
"账号"
:
self
.
item
,
"户名"
:
self
.
item
,
"开户行"
:
self
.
item
,
...
...
@@ -228,18 +229,32 @@ class Finder:
loan_term
[
'words'
]
=
words
return
loan_term
def
get_standard_rate
(
self
,
page_num
=
'0'
):
standard_rate
=
self
.
item
.
copy
()
for
block
in
self
.
pdf_info
[
page_num
][
'blocks'
]:
if
block
[
'type'
]
!=
0
:
continue
for
line
in
block
[
'lines'
]:
for
span
in
line
[
'spans'
]:
bbox
,
text
=
span
[
'bbox'
],
span
[
'text'
]
matchs
=
re
.
search
(
r'本合同当期的标准利率为(\S+)
%
/年'
,
text
)
if
matchs
:
standard_rate
[
'position'
]
=
bbox
standard_rate
[
'words'
]
=
matchs
.
group
(
1
)
return
standard_rate
def
mergelist
(
self
,
text_list
):
pattern
=
re
.
compile
(
"[^
\u4e00
-
\u9fa5
]"
)
# 匹配不是中文的其他字符
mergeindex
=
-
1
for
index
,
i
in
enumerate
(
text_list
):
if
'所购'
in
i
and
len
(
pattern
.
sub
(
''
,
pattern
.
sub
(
''
,
text_list
[
index
+
1
])))
!=
0
:
if
'所购'
in
i
and
len
(
pattern
.
sub
(
''
,
pattern
.
sub
(
''
,
text_list
[
index
+
1
])))
!=
0
:
# if '所购' in i and '.00' not in text_list[index+1]:
mergeindex
=
index
if
mergeindex
==
-
1
:
return
text_list
else
:
new_text_list
=
text_list
[:
mergeindex
]
+
[
text_list
[
mergeindex
]
+
text_list
[
mergeindex
+
1
]]
+
text_list
[
mergeindex
+
2
:]
new_text_list
=
text_list
[:
mergeindex
]
+
[
text_list
[
mergeindex
]
+
text_list
[
mergeindex
+
1
]]
+
\
text_list
[
mergeindex
+
2
:]
return
self
.
mergelist
(
new_text_list
)
def
get_asp_details
(
self
,
page_num
):
...
...
@@ -261,13 +276,13 @@ class Finder:
# print(text)
asp_details_text_list
.
append
(
text
)
asp_details_text_list
=
self
.
mergelist
(
asp_details_text_list
)
for
i
in
range
((
len
(
asp_details_text_list
)
+
2
)
//
3
):
for
i
in
range
((
len
(
asp_details_text_list
)
+
2
)
//
3
):
line
=
[]
if
i
==
0
:
line
=
[
asp_details_text_list
[
0
]]
else
:
for
j
in
range
(
3
):
line
.
append
(
asp_details_text_list
[
i
*
3
-
2
+
j
])
line
.
append
(
asp_details_text_list
[
i
*
3
-
2
+
j
])
asp_details_table
.
append
(
line
)
if
len
(
asp_details_table
)
>
0
:
asp_details_table_term
[
'words'
]
=
asp_details_table
...
...
@@ -420,12 +435,12 @@ class Finder:
table
=
False
if
table
==
True
:
repayment_schedule_text_list
.
append
(
text
)
for
i
in
range
(
len
(
repayment_schedule_text_list
)
//
5
):
for
i
in
range
(
len
(
repayment_schedule_text_list
)
//
5
):
line
=
[]
# 5表示5列的意思
for
j
in
range
(
5
):
line
.
append
(
repayment_schedule_text_list
[
i
*
5
+
j
])
if
str
(
i
+
1
)
==
line
[
1
]:
line
.
append
(
repayment_schedule_text_list
[
i
*
5
+
j
])
if
str
(
i
+
1
)
==
line
[
1
]:
break
repayment_schedule_table
.
append
(
line
)
if
len
(
repayment_schedule_table
)
>
0
:
...
...
@@ -461,8 +476,7 @@ class Finder:
else
:
words
=
'无'
boxes
=
np
.
array
(
boxes
)
.
reshape
((
-
1
,
2
))
position
=
[
min
(
boxes
[:,
0
]),
min
(
boxes
[:,
1
]),
max
(
boxes
[:,
0
]),
max
(
boxes
[:,
1
])]
position
=
[
min
(
boxes
[:,
0
]),
min
(
boxes
[:,
1
]),
max
(
boxes
[:,
0
]),
max
(
boxes
[:,
1
])]
signature_role_1
[
'page_num'
]
=
page_num
signature_role_1
[
'position'
]
=
position
signature_role_1
[
'words'
]
=
words
...
...
@@ -497,8 +511,7 @@ class Finder:
else
:
words
=
'无'
boxes
=
np
.
array
(
boxes
)
.
reshape
((
-
1
,
2
))
position
=
[
min
(
boxes
[:,
0
]),
min
(
boxes
[:,
1
]),
max
(
boxes
[:,
0
]),
max
(
boxes
[:,
1
])]
position
=
[
min
(
boxes
[:,
0
]),
min
(
boxes
[:,
1
]),
max
(
boxes
[:,
0
]),
max
(
boxes
[:,
1
])]
signature_role_2
[
'page_num'
]
=
page_num
signature_role_2
[
'position'
]
=
position
signature_role_2
[
'words'
]
=
words
...
...
@@ -533,8 +546,7 @@ class Finder:
else
:
words
=
'无'
boxes
=
np
.
array
(
boxes
)
.
reshape
((
-
1
,
2
))
position
=
[
min
(
boxes
[:,
0
]),
min
(
boxes
[:,
1
]),
max
(
boxes
[:,
0
]),
max
(
boxes
[:,
1
])]
position
=
[
min
(
boxes
[:,
0
]),
min
(
boxes
[:,
1
]),
max
(
boxes
[:,
0
]),
max
(
boxes
[:,
1
])]
signature_role_3
[
'page_num'
]
=
page_num
signature_role_3
[
'position'
]
=
position
signature_role_3
[
'words'
]
=
words
...
...
@@ -569,8 +581,7 @@ class Finder:
else
:
words
=
'无'
boxes
=
np
.
array
(
boxes
)
.
reshape
((
-
1
,
2
))
position
=
[
min
(
boxes
[:,
0
]),
min
(
boxes
[:,
1
]),
max
(
boxes
[:,
0
]),
max
(
boxes
[:,
1
])]
position
=
[
min
(
boxes
[:,
0
]),
min
(
boxes
[:,
1
]),
max
(
boxes
[:,
0
]),
max
(
boxes
[:,
1
])]
signature_role_4
[
'page_num'
]
=
page_num
signature_role_4
[
'position'
]
=
position
signature_role_4
[
'words'
]
=
words
...
...
@@ -606,8 +617,7 @@ class Finder:
else
:
words
=
'无'
boxes
=
np
.
array
(
boxes
)
.
reshape
((
-
1
,
2
))
position
=
[
min
(
boxes
[:,
0
]),
min
(
boxes
[:,
1
]),
max
(
boxes
[:,
0
]),
max
(
boxes
[:,
1
])]
position
=
[
min
(
boxes
[:,
0
]),
min
(
boxes
[:,
1
]),
max
(
boxes
[:,
0
]),
max
(
boxes
[:,
1
])]
signature_role_5
[
'page_num'
]
=
page_num
signature_role_5
[
'position'
]
=
position
signature_role_5
[
'words'
]
=
words
...
...
@@ -699,27 +709,22 @@ class Finder:
contract_no
=
self
.
get_contract_no
(
page_num
=
'0'
)
self
.
init_result
[
'page_2'
][
'合同编号'
]
=
contract_no
# 找借款人及抵押人(地址字段原本有空格)
borrower_name
,
borrower_id
=
self
.
get_somebody
(
top
=
'借款人及抵押人:'
,
bottom
=
'共同借款人:'
)
borrower_name
,
borrower_id
=
self
.
get_somebody
(
top
=
'借款人及抵押人:'
,
bottom
=
'共同借款人:'
)
# 这是为了同时兼容 8.1 版本
if
borrower_name
[
'words'
]
==
None
:
borrower_name
,
borrower_id
=
self
.
get_somebody
(
top
=
'借款人及抵押人:'
,
bottom
=
'共同借款人及共同抵押人:'
)
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
# 找共同借款人及共同抵押人
co_borrower_name
,
co_borrower_id
=
self
.
get_somebody
(
top
=
'共同借款人:'
,
bottom
=
'保证人1:'
)
co_borrower_name
,
co_borrower_id
=
self
.
get_somebody
(
top
=
'共同借款人:'
,
bottom
=
'保证人1:'
)
self
.
init_result
[
'page_2'
][
'共同借款人及共同抵押人'
][
'name'
]
=
co_borrower_name
self
.
init_result
[
'page_2'
][
'共同借款人及共同抵押人'
][
'id'
]
=
co_borrower_id
# 保证人1
first_guarantor_name
,
first_guarantor_id
=
self
.
get_somebody
(
top
=
'保证人1:'
,
bottom
=
'保证人2:'
)
first_guarantor_name
,
first_guarantor_id
=
self
.
get_somebody
(
top
=
'保证人1:'
,
bottom
=
'保证人2:'
)
self
.
init_result
[
'page_2'
][
'保证人1'
][
'name'
]
=
first_guarantor_name
self
.
init_result
[
'page_2'
][
'保证人1'
][
'id'
]
=
first_guarantor_id
# 保证人2
second_guarantor_name
,
second_guarantor_id
=
self
.
get_somebody
(
top
=
'保证人2:'
,
bottom
=
'第一章'
)
second_guarantor_name
,
second_guarantor_id
=
self
.
get_somebody
(
top
=
'保证人2:'
,
bottom
=
'第一章'
)
self
.
init_result
[
'page_2'
][
'保证人2'
][
'name'
]
=
second_guarantor_name
self
.
init_result
[
'page_2'
][
'保证人2'
][
'id'
]
=
second_guarantor_id
# 所购车辆价格
...
...
@@ -740,6 +745,9 @@ class Finder:
# 贷款期限
loan_term
=
self
.
get_loan_term
(
page_num
=
'1'
)
self
.
init_result
[
'page_2'
][
'贷款期限'
]
=
loan_term
# 本合同当期的标准利率
standard_rate
=
self
.
get_standard_rate
(
page_num
=
'1'
)
self
.
init_result
[
'page_2'
][
'标准利率'
]
=
standard_rate
# 还款账户
account
,
account_name
,
account_bank
=
self
.
get_payback_account
()
self
.
init_result
[
'page_2'
][
'还款账户'
][
'账号'
]
=
account
...
...
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