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
13bc06a8
authored
2021-04-14 13:44:49 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix bug
1 parent
3744ea66
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
9 deletions
src/celery_compare/tasks.py
src/common/tools/comparison.py
src/celery_compare/tasks.py
View file @
13bc06a
...
...
@@ -38,7 +38,7 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set):
ocr_str
=
ocr_res
.
get
(
compare_tuple
[
1
])
compare_res
,
ocr_output
=
getattr
(
cp
,
compare_tuple
[
2
])(
input_str
,
ocr_str
,
idx
,
**
compare_tuple
[
3
])
if
idx
==
0
and
compare_res
==
consts
.
RESULT_N
:
if
idx
==
0
and
compare_res
in
[
consts
.
RESULT_N
,
consts
.
RESULT_NA
]
:
break
is_find
=
True
info_dict
[
compare_tuple
[
4
]]
=
compare_res
...
...
@@ -70,7 +70,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s
ocr_str
=
ocr_res
.
get
(
compare_tuple
[
1
])
compare_res
,
ocr_output
=
getattr
(
cp
,
compare_tuple
[
2
])(
input_str
,
ocr_str
,
idx
,
**
compare_tuple
[
3
])
if
idx
==
0
and
compare_res
==
consts
.
RESULT_N
:
if
idx
==
0
and
compare_res
in
[
consts
.
RESULT_N
,
consts
.
RESULT_NA
]
:
if
ocr_str
is
not
None
:
no_match_vino
.
append
(
ocr_str
)
break
...
...
@@ -85,7 +85,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s
if
not
is_find
:
res_set
.
add
(
consts
.
RESULT_N
)
for
idx
,
compare_tuple
in
enumerate
(
compare_list
):
info_dict
[
compare_tuple
[
4
]]
=
consts
.
RESULT_N
info_dict
[
compare_tuple
[
4
]]
=
consts
.
RESULT_N
A
if
idx
==
0
:
continue
if
compare_tuple
[
0
]
in
info_dict
:
...
...
@@ -194,7 +194,7 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id):
comparison_res
[
'OCR_Input'
][
'corporateCusInfo'
]
=
order_corporate_cus_info
comparison_res
[
'OCR_Input'
][
'wholeResult'
]
=
consts
.
RESULT_N
if
consts
.
RESULT_N
in
res_set
else
consts
.
RESULT_Y
comparison_res
[
'OCR_Input'
][
'wholeResult'
]
=
consts
.
RESULT_N
if
consts
.
RESULT_N
in
res_set
or
consts
.
RESULT_NA
in
res_set
else
consts
.
RESULT_Y
except
Exception
as
e
:
compare_log
.
error
(
'{0} [compare error] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] '
...
...
src/common/tools/comparison.py
View file @
13bc06a
...
...
@@ -35,13 +35,17 @@ class Comparison:
return
self
.
RESULT_N
def
common_compare
(
self
,
input_str
,
ocr_str
,
idx
,
**
kwargs
):
if
ocr_str
==
''
:
return
self
.
RESULT_NA
,
None
if
not
isinstance
(
input_str
,
str
)
or
not
isinstance
(
ocr_str
,
str
):
return
self
.
RESULT_N
,
ocr_str
return
self
.
RESULT_N
A
,
ocr_str
return
self
.
build_res
(
input_str
==
ocr_str
),
ocr_str
def
name_compare
(
self
,
input_str
,
ocr_str
,
idx
,
**
kwargs
):
if
ocr_str
==
''
:
return
self
.
RESULT_NA
,
None
if
not
isinstance
(
input_str
,
str
)
or
not
isinstance
(
ocr_str
,
str
):
return
self
.
RESULT_N
,
ocr_str
return
self
.
RESULT_N
A
,
ocr_str
if
kwargs
.
get
(
'is_passport'
):
input_obj
=
re
.
search
(
r'[a-zA-Z]]!'
,
input_str
)
if
input_obj
:
...
...
@@ -61,8 +65,10 @@ class Comparison:
return
self
.
build_res
(
input_s
==
ocr_s
),
ocr_str
def
date_compare
(
self
,
input_str
,
ocr_str
,
idx
,
**
kwargs
):
if
ocr_str
==
''
:
return
self
.
RESULT_NA
,
None
if
not
isinstance
(
input_str
,
str
)
or
not
isinstance
(
ocr_str
,
str
):
return
self
.
RESULT_N
,
ocr_str
return
self
.
RESULT_N
A
,
ocr_str
if
kwargs
.
get
(
'long'
,
False
)
and
'长期'
in
ocr_str
:
return
self
.
RESULT_Y
,
'2099-12-31'
if
kwargs
.
get
(
'ocr_split'
,
False
):
...
...
@@ -85,7 +91,12 @@ class Comparison:
def
rmb_compare
(
self
,
input_str
,
ocr_str
,
idx
,
**
kwargs
):
if
not
isinstance
(
input_str
,
str
)
or
not
isinstance
(
ocr_str
,
str
):
return
self
.
RESULT_N
,
None
return
self
.
RESULT_NA
,
None
if
ocr_str
==
''
:
if
input_str
==
'0.0'
:
return
self
.
RESULT_Y
,
input_str
else
:
return
self
.
RESULT_N
,
'0.0'
try
:
input_rmb_upper
=
to_rmb_upper
(
float
(
input_str
))
res
=
self
.
build_res
(
input_rmb_upper
==
ocr_str
)
...
...
@@ -98,8 +109,10 @@ class Comparison:
return
res
,
None
def
type_compare
(
self
,
input_str
,
ocr_str
,
idx
,
**
kwargs
):
if
ocr_str
==
''
:
return
self
.
RESULT_NA
,
None
if
not
isinstance
(
input_str
,
str
)
or
not
isinstance
(
ocr_str
,
str
):
return
self
.
RESULT_N
,
ocr_str
return
self
.
RESULT_N
A
,
ocr_str
for
map_tuple
in
self
.
TYPE_MAPPING
:
if
re
.
search
(
map_tuple
[
0
],
ocr_str
)
is
not
None
:
compare_str
=
map_tuple
[
1
]
...
...
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