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
301c6d7d
authored
2021-08-23 11:05:29 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add ltgt yh
1 parent
1d68ef28
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
src/apps/doc/management/commands/folder_ltgt_process.py
src/apps/doc/ocr/wb.py
src/apps/doc/management/commands/folder_ltgt_process.py
View file @
301c6d7
...
...
@@ -50,6 +50,7 @@ class Command(BaseCommand, LoggerMixin):
self
.
log_base
=
'[folder ltgt process]'
# 处理文件开关
self
.
switch
=
True
self
.
amount_key_set
=
{
'债权金额'
,
'贷款本金'
,
'罚息'
,
'律师费'
,
'案件受理费'
,
'支付金额'
}
self
.
ltgt_classify_mapping
=
{
128
:
'执行裁定书'
,
129
:
'民事判决书'
,
...
...
@@ -287,7 +288,7 @@ class Command(BaseCommand, LoggerMixin):
result_dict
=
ocr_res
.
get
(
'data'
,
{})
wb
=
BSWorkbook
(
set
(),
set
(),
set
(),
set
(),
set
())
rebuild_res
=
wb
.
ltgt_build
(
label
,
result_dict
)
rebuild_res
=
wb
.
ltgt_build
(
label
,
result_dict
,
self
.
amount_key_set
)
wb
.
remove_base_sheet
()
wb
.
save
(
excel_path
)
return
rebuild_res
...
...
src/apps/doc/ocr/wb.py
View file @
301c6d7
...
...
@@ -702,7 +702,14 @@ class BSWorkbook(Workbook):
if
field_str
is
not
None
:
count_list
.
append
((
field_str
,
count
))
def
ltgt_build
(
self
,
label
,
result_dict
):
@staticmethod
def
remove_yuan
(
amount_key_set
,
key
,
src_str
):
if
key
in
amount_key_set
and
isinstance
(
src_str
,
str
):
return
src_str
.
replace
(
'元'
,
''
)
else
:
return
src_str
def
ltgt_build
(
self
,
label
,
result_dict
,
amount_key_set
):
ws
=
self
.
create_sheet
(
label
)
rebuild_res
=
{}
for
key
,
value
in
result_dict
.
items
():
...
...
@@ -712,19 +719,23 @@ class BSWorkbook(Workbook):
rebuild_res
[
key
]
=
'、'
.
join
(
value_list
)
elif
isinstance
(
value
,
dict
):
if
'words'
in
value
:
ws
.
append
((
key
,
value
[
'words'
]))
rebuild_res
[
key
]
=
value
[
'words'
]
new_value
=
self
.
remove_yuan
(
amount_key_set
,
key
,
value
[
'words'
])
ws
.
append
((
key
,
new_value
))
rebuild_res
[
key
]
=
new_value
else
:
for
sub_key
,
sub_value
in
value
.
items
():
if
isinstance
(
sub_value
,
dict
):
ws
.
append
((
'{0}: {1}'
.
format
(
key
,
sub_key
),
sub_value
.
get
(
'words'
,
''
)))
rebuild_res
[
'{0}: {1}'
.
format
(
key
,
sub_key
)]
=
sub_value
.
get
(
'words'
,
''
)
new_value
=
self
.
remove_yuan
(
amount_key_set
,
sub_key
,
sub_value
.
get
(
'words'
,
''
))
ws
.
append
((
'{0}: {1}'
.
format
(
key
,
sub_key
),
new_value
))
rebuild_res
[
'{0}: {1}'
.
format
(
key
,
sub_key
)]
=
new_value
else
:
ws
.
append
((
'{0}: {1}'
.
format
(
key
,
sub_key
),
sub_value
))
rebuild_res
[
'{0}: {1}'
.
format
(
key
,
sub_key
)]
=
sub_value
new_value
=
self
.
remove_yuan
(
amount_key_set
,
sub_key
,
sub_value
)
ws
.
append
((
'{0}: {1}'
.
format
(
key
,
sub_key
),
new_value
))
rebuild_res
[
'{0}: {1}'
.
format
(
key
,
sub_key
)]
=
new_value
else
:
ws
.
append
((
key
,
value
))
rebuild_res
[
key
]
=
value
new_value
=
self
.
remove_yuan
(
amount_key_set
,
key
,
value
)
ws
.
append
((
key
,
new_value
))
rebuild_res
[
key
]
=
new_value
return
rebuild_res
def
simple_license_rebuild
(
self
,
license_summary
,
document_scheme
):
...
...
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