Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lichenggang
/
bom_identify
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e41b463e
authored
Jun 29, 2020
by
lichenggang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化
parent
b9ac888b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
15 deletions
predict/txt_predict.py
predict/txt_predict.py
View file @
e41b463e
...
...
@@ -18,7 +18,6 @@ class TxtPredict(BasePredictor):
def
pre_deal
(
self
,
li
:
list
):
data
=
[]
resp
=
{}
for
row_index
,
i
in
enumerate
(
li
):
raw_items
=
re
.
split
(
r'(?:,|,|;|\s)\s*'
,
i
)
no_null_raw_items
=
[
j
.
strip
()
for
j
in
raw_items
if
j
.
strip
()]
...
...
@@ -26,22 +25,13 @@ class TxtPredict(BasePredictor):
'qty'
:
None
,
'brand'
:
None
,
'gn_or_param'
:
None
,
'statu_code'
:
1
}
for
item
in
no_null_raw_items
:
if
self
.
isnum
(
item
):
resp_data
[
'qty'
]
=
item
no_null_raw_items
.
remove
(
item
)
break
else
:
resp_data
=
{
'message'
:
'未检测到数量'
,
'statu_code'
:
0
}
resp
[
row_index
]
=
resp_data
data
.
append
((
row_index
,
resp_data
,
no_null_raw_items
))
continue
if
not
no_null_raw_items
:
resp_data
=
{
'message'
:
'未检测到参数/型号'
,
'statu_code'
:
0
}
resp
[
row_index
]
=
resp_data
data
.
append
((
row_index
,
resp_data
,
no_null_raw_items
))
return
data
...
...
@@ -50,11 +40,9 @@ class TxtPredict(BasePredictor):
data
=
self
.
pre_deal
(
li
)
resp
=
{}
for
row_index
,
resp_data
,
nonull_nonum_items
in
data
:
if
resp_data
[
'statu_code'
]
==
0
:
resp
[
row_index
]
=
resp_data
continue
if
len
(
nonull_nonum_items
)
==
1
:
if
not
nonull_nonum_items
:
pass
elif
len
(
nonull_nonum_items
)
==
1
:
resp_data
[
'gn_or_param'
]
=
nonull_nonum_items
[
0
]
elif
len
(
nonull_nonum_items
)
>=
2
:
result_1
,
prab
=
self
.
get_single_predict
(
nonull_nonum_items
[
-
1
],
BasePredictor
.
model
,
BasePredictor
.
extractor
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment