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
47957ad9
authored
Jun 01, 2020
by
lichenggang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
增加类别
parent
d2477e8b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
77 deletions
predict/base_handler.py
predict/dict_predict.py
predict/list_predict.py
predict/base_handler.py
View file @
47957ad9
...
...
@@ -6,8 +6,8 @@ from collections import Counter
from
utils.log_manager
import
get_logger
from
utils.robots
import
dd_send_msg
import
pandas
as
pd
from
static_config
import
*
CATEGORY
=
[
'二极管'
]
RIGHT_LEVEL
=
0.7
SEQ_LEVEL
=
0.5
CATE_LEVEL
=
0.5
...
...
predict/dict_predict.py
View file @
47957ad9
...
...
@@ -112,8 +112,8 @@ class DicPredict(BasePredictor):
if
self
.
is_catecol
(
v
):
temp_pre_model_res
[
k
]
=
'类别'
continue
temp
_dic_data
=
{
k
:
list
(
filter
(
lambda
x
:
x
!=
self
.
PLACEHOLDER
,
dic_data
[
k
]))
for
k
in
prob_columns
}
for
k
,
v
in
temp
_dic_data
.
items
():
not_null
_dic_data
=
{
k
:
list
(
filter
(
lambda
x
:
x
!=
self
.
PLACEHOLDER
,
dic_data
[
k
]))
for
k
in
prob_columns
}
for
k
,
v
in
not_null
_dic_data
.
items
():
li_single_pred_res
=
[]
for
string
in
v
:
single_pred_res
,
probdic
=
self
.
get_single_predict
(
string
)
...
...
@@ -125,8 +125,9 @@ class DicPredict(BasePredictor):
prob_param_and_gn_cols
=
[
i
for
i
in
temp_pre_model_res
if
temp_pre_model_res
[
i
]
==
'参数'
or
temp_pre_model_res
[
i
]
==
'型号'
]
for
col
in
prob_param_and_gn_cols
:
if
self
.
is_multi_same
(
temp
_dic_data
[
col
]):
if
self
.
is_multi_same
(
not_null
_dic_data
[
col
]):
temp_pre_model_res
.
pop
(
col
)
model_id_res
=
{
'std_result'
:
temp_pre_model_res
,
'ab_result'
:
ab_result
,
...
...
@@ -148,7 +149,7 @@ class DicPredict(BasePredictor):
if
comprehensive_res
:
res
=
{
'std_result'
:
comprehensive_res
,
'ab_result'
:
pre_id_res
[
'ab_result'
]
or
model_std_result
[
'ab_result'
]
,
'ab_result'
:
pre_id_res
[
'ab_result'
],
}
return
res
...
...
predict/list_predict.py
deleted
100644 → 0
View file @
d2477e8b
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import
re
from
predict.base_handler
import
BasePredictor
RIGHT_LEVEL
=
0.7
REPEAT_TIMES
=
3
class
LiPredict
(
BasePredictor
):
def
predict
(
self
,
key
):
# if len(key) > 0:
# self.order_predict(key[1])
for
ix
in
key
:
self
.
num_predict
(
key
[
ix
])
pass
"""
序列预测
"""
def
order_predict
(
self
,
data
):
collect_order
=
[
int
(
kw
)
for
kw
in
data
if
isinstance
(
kw
,
float
)
or
isinstance
(
kw
,
int
)]
judge
=
self
.
isIncrease
(
collect_order
,
len
(
collect_order
))
if
len
(
collect_order
)
>
0
else
False
print
(
'judge: '
+
str
(
judge
))
return
judge
"""
数量预测
"""
def
num_predict
(
self
,
data
):
collect_num
=
[
kw
for
kw
in
data
if
isinstance
(
kw
,
int
)
or
self
.
isNumberCol
(
kw
)]
rate
=
round
(
len
(
collect_num
)
/
len
(
data
),
3
)
return
True
if
rate
>=
RIGHT_LEVEL
else
False
"""
判断列表元素是否递增
"""
def
isIncrease
(
self
,
arr
,
size
):
if
size
==
1
:
return
True
return
(
arr
[
size
-
1
]
>=
arr
[
size
-
2
])
and
self
.
isIncrease
(
arr
,
size
-
1
)
"""
判断是否数量列
"""
def
isNumberCol
(
self
,
kw
):
if
isinstance
(
kw
,
str
):
return
re
.
match
(
r'(\d+)((K)|([\u4E00-\u9FA5]{1,3}))$'
,
kw
,
re
.
M
|
re
.
I
)
else
:
return
False
def
isRepeat
(
self
,
data
):
repeat_dict
=
{}
for
kw
in
data
:
if
repeat_dict
.
get
(
kw
):
repeat_dict
[
kw
]
+=
1
else
:
repeat_dict
[
kw
]
=
1
print
(
repeat_dict
)
#
# """
# 判断是否重复列
# """
# def vailed(self, data):
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