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
31d69c11
authored
2020-11-12 11:34:12 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix bug
1 parent
188c4102
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
7 deletions
src/apps/doc/consts.py
src/apps/doc/management/commands/folder_ocr_process.py
src/apps/doc/management/commands/ocr_process.py
src/apps/doc/ocr/wb.py
src/common/tools/mssql_script.py
src/apps/doc/consts.py
View file @
31d69c1
...
...
@@ -902,6 +902,7 @@ NYYH_CLASSIFY = 17
MS_CLASSIFY
=
21
MS_ERROR_COL
=
(
5
,
6
)
WECHART_CLASSIFY
=
12
ALI_WECHART_CLASSIFY
=
{
12
,
13
}
WECHART_ERROR_COL
=
(
1
,
2
)
WECHART_HEADERS_MAPPING
=
copy
.
deepcopy
(
HEADERS_MAPPING
)
WECHART_HEADERS_MAPPING
.
update
(
...
...
src/apps/doc/management/commands/folder_ocr_process.py
View file @
31d69c1
...
...
@@ -91,7 +91,7 @@ class Command(BaseCommand, LoggerMixin):
else
:
res_list
.
append
((
pno
,
ino
,
part_idx
,
consts
.
RES_FAILED
))
wb
=
BSWorkbook
(
set
(),
set
(),
set
())
wb
=
BSWorkbook
(
set
(),
set
(),
set
()
,
set
()
)
wb
.
simple_license_rebuild
(
license_summary
,
consts
.
DOC_SCHEME_LIST
[
0
])
wb
.
save
(
excel_path
)
except
Exception
as
e
:
...
...
src/apps/doc/management/commands/ocr_process.py
View file @
31d69c1
...
...
@@ -489,9 +489,10 @@ class Command(BaseCommand, LoggerMixin):
salary_keyword
=
Keywords
.
objects
.
filter
(
type
=
KeywordsType
.
SALARY
.
value
,
on_off
=
True
)
.
values_list
(
'keyword'
,
flat
=
True
)
loan_keyword
=
Keywords
.
objects
.
filter
(
type__in
=
[
KeywordsType
.
LOAN
.
value
,
KeywordsType
.
ALI_WECHART
.
value
],
on_off
=
True
)
.
values_list
(
'keyword'
,
flat
=
True
)
wb
=
BSWorkbook
(
interest_keyword
,
salary_keyword
,
loan_keyword
)
type
=
KeywordsType
.
LOAN
.
value
,
on_off
=
True
)
.
values_list
(
'keyword'
,
flat
=
True
)
wechat_keyword
=
Keywords
.
objects
.
filter
(
type
=
KeywordsType
.
ALI_WECHART
.
value
,
on_off
=
True
)
.
values_list
(
'keyword'
,
flat
=
True
)
wb
=
BSWorkbook
(
interest_keyword
,
salary_keyword
,
loan_keyword
,
wechat_keyword
)
for
img_path
,
res
in
ocr_1_res
.
items
():
pno
,
ino
=
self
.
parse_img_path
(
img_path
)
part_idx
=
1
...
...
src/apps/doc/ocr/wb.py
View file @
31d69c1
...
...
@@ -13,7 +13,7 @@ from apps.doc import consts
class
BSWorkbook
(
Workbook
):
def
__init__
(
self
,
interest_keyword
,
salary_keyword
,
loan_keyword
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
interest_keyword
,
salary_keyword
,
loan_keyword
,
wechat_keyword
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
locale
.
setlocale
(
locale
.
LC_NUMERIC
,
'en_US.UTF-8'
)
self
.
meta_sheet_title
=
'关键信息提取和展示'
...
...
@@ -24,6 +24,7 @@ class BSWorkbook(Workbook):
self
.
interest_keyword
=
interest_keyword
self
.
salary_keyword
=
salary_keyword
self
.
loan_keyword
=
loan_keyword
self
.
wechat_keyword
=
wechat_keyword
self
.
proof_res
=
(
'对'
,
'错'
)
self
.
loan_fill
=
PatternFill
(
"solid"
,
fgColor
=
"00FFCC00"
)
self
.
amount_fill
=
PatternFill
(
"solid"
,
fgColor
=
"00FFFF00"
)
...
...
@@ -309,6 +310,7 @@ class BSWorkbook(Workbook):
else
:
# 364,92
pre_idx
=
period_idx
res_str
=
'{0}.{1}'
.
format
(
res_str
[:
pre_idx
],
res_str
[
period_idx
+
1
:])
res_str
=
res_str
[:
period_idx
]
.
replace
(
'.'
,
''
)
+
res_str
[
period_idx
:]
return
res_str
@staticmethod
...
...
@@ -372,6 +374,10 @@ class BSWorkbook(Workbook):
result_idx
=
len
(
header
)
-
1
tmp_ws
=
self
.
create_sheet
(
'tmp_ws'
)
if
classify
in
consts
.
ALI_WECHART_CLASSIFY
:
high_light_keyword
=
self
.
wechat_keyword
else
:
high_light_keyword
=
self
.
loan_keyword
for
month
in
sorted
(
month_mapping
.
keys
()):
# 3.1.拷贝数据
parts
=
month_mapping
.
get
(
month
)
...
...
@@ -419,7 +425,7 @@ class BSWorkbook(Workbook):
elif
summary_cell_value
in
self
.
salary_keyword
:
tmp_ws
.
append
((
summary_cell_value
,
date_cell_value
,
amount_cell_value
))
# 贷款关键词高亮
elif
summary_cell_value
in
self
.
loan
_keyword
:
elif
summary_cell_value
in
high_light
_keyword
:
summary_cell
.
fill
=
self
.
amount_fill
if
amount_cell
is
not
None
:
amount_cell
.
fill
=
self
.
amount_fill
...
...
src/common/tools/mssql_script.py
View file @
31d69c1
...
...
@@ -456,7 +456,7 @@ afc_sql = """
"""
keywords_sql
=
"""
INSERT INTO
afc.dbo.
keywords (keyword, type, update_time, create_time) VALUES
INSERT INTO keywords (keyword, type, update_time, create_time) VALUES
(N'利息', 0, N'2020-11-09 16:14:58.000', N'2020-11-09 16:14:59.000'),
(N'结息', 0, N'2020-11-09 16:14:58.000', N'2020-11-09 16:14:59.000'),
(N'工资', 1, N'2020-11-09 16:14:58.000', N'2020-11-09 16:14:59.000'),
...
...
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