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
2a7c1a81
authored
2021-06-14 00:10:42 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
role name highlight & modify amount highlight
1 parent
a017b458
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
src/apps/doc/ocr/wb.py
src/apps/doc/ocr/wb.py
View file @
2a7c1a8
...
...
@@ -403,7 +403,7 @@ class BSWorkbook(Workbook):
row_value
[
1
]
=
'
\n
'
.
join
(
append_list
)
return
row_value
def
build_month_sheet
(
self
,
ms
,
card
,
month_mapping
,
is_reverse
,
statistics_header_info
,
max_column
,
classify
):
def
build_month_sheet
(
self
,
ms
,
role_name
,
card
,
month_mapping
,
is_reverse
,
statistics_header_info
,
max_column
,
classify
):
summary_cell_idx
=
statistics_header_info
.
get
(
consts
.
SUMMARY_KEY
)
date_cell_idx
=
statistics_header_info
.
get
(
consts
.
DATE_KEY
)
amount_cell_idx
=
statistics_header_info
.
get
(
consts
.
AMOUNT_KEY
)
# None or src or append
...
...
@@ -450,7 +450,7 @@ class BSWorkbook(Workbook):
amount_mapping
=
{}
amount_fill_row
=
set
()
loan_
fill_row
=
set
()
fill_row
=
set
()
# 添加筛选
new_ws
.
auto_filter
.
ref
=
'A1:{0}{1}'
.
format
(
get_column_letter
(
new_ws
.
max_column
),
new_ws
.
max_row
)
...
...
@@ -475,7 +475,13 @@ class BSWorkbook(Workbook):
# 贷款关键词高亮
if
summary_cell
is
not
None
and
summary_cell_value
in
high_light_keyword
:
loan_fill_row
.
add
(
summary_cell
.
row
)
fill_row
.
add
(
summary_cell
.
row
)
# 户名高亮
for
cell
in
rows
:
if
cell
.
value
==
role_name
:
fill_row
.
add
(
summary_cell
.
row
)
break
# 3.3.余额转数值
over_success
=
False
...
...
@@ -514,12 +520,13 @@ class BSWorkbook(Workbook):
amount_cell
.
number_format
=
numbers
.
FORMAT_NUMBER_00
if
date_cell
is
not
None
and
isinstance
(
date_cell_value
,
str
):
same_amount_mapping
=
amount_mapping
.
get
(
date_cell_value
[:
10
],
{})
fill_rows
=
same_amount_mapping
.
get
(
-
amount_cell
.
value
)
if
fill_rows
:
fill_rows
_set
=
same_amount_mapping
.
get
(
-
amount_cell
.
value
,
set
()
)
if
len
(
fill_rows_set
)
>
0
:
amount_fill_row
.
add
(
amount_cell
.
row
)
amount_fill_row
.
update
(
fill_rows
)
amount_fill_row
.
add
(
fill_rows_set
.
pop
())
else
:
amount_mapping
.
setdefault
(
date_cell_value
[:
10
],
{})
.
setdefault
(
amount_cell
.
value
,
[])
.
appen
d
(
amount_cell
.
row
)
amount_cell
.
value
,
set
())
.
ad
d
(
amount_cell
.
row
)
# 3.5.核对结果
if
amount_success
and
over_success
and
amount_cell
.
row
>
2
:
...
...
@@ -553,7 +560,7 @@ class BSWorkbook(Workbook):
# if amount_cell is not None:
# amount_cell.fill = self.amount_fill
for
row
in
loan_
fill_row
:
for
row
in
fill_row
:
for
cell
in
new_ws
[
row
]:
cell
.
fill
=
self
.
amount_fill
...
...
@@ -598,6 +605,7 @@ class BSWorkbook(Workbook):
new_card
=
self
.
get_new_card
(
card
)
# 1.原表表头收集、按照月份分割
# 1.1 总结首行信息
role_name
=
summary
.
get
(
'role'
,
consts
.
UNKNOWN_ROLE
)
classify
=
summary
.
get
(
'classify'
,
0
)
sheet_header_info
=
{}
header_info
=
{}
...
...
@@ -634,7 +642,7 @@ class BSWorkbook(Workbook):
# 2.元信息提取表
confidence
=
self
.
get_confidence
(
max_find_count
)
ms
=
self
.
build_meta_sheet
(
summary
.
get
(
'role'
,
consts
.
UNKNOWN_ROLE
)
,
ms
=
self
.
build_meta_sheet
(
role_name
,
new_card
,
confidence
,
summary
.
get
(
'code'
),
...
...
@@ -648,7 +656,7 @@ class BSWorkbook(Workbook):
for
month_list
in
month_mapping
.
values
():
month_list
.
sort
(
key
=
lambda
x
:
x
[
-
1
],
reverse
=
is_reverse
)
self
.
build_month_sheet
(
ms
,
new_card
,
month_mapping
,
is_reverse
,
statistics_header_info
,
max_column
,
classify
)
self
.
build_month_sheet
(
ms
,
role_name
,
new_card
,
month_mapping
,
is_reverse
,
statistics_header_info
,
max_column
,
classify
)
# 4.删除原表
for
sheet
in
sheets_list
:
...
...
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