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
304cf454
authored
May 28, 2020
by
lzzzzl
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
新增识别序号列
parent
e9424909
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
3 deletions
DZ0901_V1.4_BOM.xlsx
classify_server.py
predict/list_predict.py
utils/excel_manager.py
utils/predic_fac.py
DZ0901_V1.4_BOM.xlsx
0 → 100644
View file @
304cf454
No preview for this file type
classify_server.py
View file @
304cf454
...
@@ -7,6 +7,7 @@ from protobuf import classify_pb2_grpc
...
@@ -7,6 +7,7 @@ from protobuf import classify_pb2_grpc
from
utils.config
import
model_config
from
utils.config
import
model_config
from
utils.predic_fac
import
PredictorFac
from
utils.predic_fac
import
PredictorFac
from
utils.log_manager
import
get_logger
from
utils.log_manager
import
get_logger
from
utils.excel_manager
import
read_from_excel
log_server
=
get_logger
(
'server'
)
log_server
=
get_logger
(
'server'
)
...
@@ -40,5 +41,8 @@ def serve():
...
@@ -40,5 +41,8 @@ def serve():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
serve
()
# serve()
# print(Classify().fac_test_predic('lm358'))
data
=
read_from_excel
(
'DZ0901_V1.4_BOM.xlsx'
,
'DZ0901_V1.3BOM清单'
)
print
(
data
)
print
(
Classify
()
.
fac_test_predic
(
data
))
predict/list_predict.py
View file @
304cf454
#!/usr/bin/env python
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# -*- coding:utf-8 -*-
from
predict.base_handler
import
BasePredictor
from
predict.base_handler
import
BasePredictor
from
utils.excel_manager
import
read_from_excel
order_list
=
[
'序号'
]
class
LiPredict
(
BasePredictor
):
class
LiPredict
(
BasePredictor
):
def
predict
(
self
,
key
):
if
len
(
key
)
>
0
:
self
.
order_predict
(
key
[
0
])
pass
pass
def
order_predict
(
self
,
data
):
collect_num
=
[
int
(
kw
)
for
kw
in
data
if
isinstance
(
kw
,
float
)
or
isinstance
(
kw
,
int
)]
judge
=
self
.
IsIncrease
(
collect_num
,
len
(
collect_num
))
print
(
'judge: '
+
str
(
judge
))
return
judge
"""
判断列表元素是否递增
"""
def
IsIncrease
(
self
,
arr
,
size
):
if
size
==
1
:
return
True
return
(
arr
[
size
-
1
]
>=
arr
[
size
-
2
])
and
self
.
IsIncrease
(
arr
,
size
-
1
)
utils/excel_manager.py
0 → 100644
View file @
304cf454
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import
xlwt
import
xlrd
def
read_from_excel
(
file_name
,
sheet_name
):
wb
=
xlrd
.
open_workbook
(
file_name
)
sheet
=
wb
.
sheet_by_name
(
sheet_name
)
row
=
sheet
.
nrows
col
=
sheet
.
ncols
result_dict
=
{}
for
i
in
range
(
col
):
col_list
=
[]
for
j
in
range
(
row
):
col_list
.
append
(
sheet
.
cell_value
(
j
,
i
))
result_dict
[
i
]
=
col_list
return
result_dict
utils/predic_fac.py
View file @
304cf454
...
@@ -15,7 +15,7 @@ class PredictorFac():
...
@@ -15,7 +15,7 @@ class PredictorFac():
def
_get_predictor
(
self
,
data
):
def
_get_predictor
(
self
,
data
):
if
isinstance
(
data
,
str
):
if
isinstance
(
data
,
str
):
return
self
.
kw_predictor
return
self
.
kw_predictor
elif
isinstance
(
data
,
lis
t
):
elif
isinstance
(
data
,
dic
t
):
return
self
.
list_predictor
return
self
.
list_predictor
def
predic
(
self
,
data
):
def
predic
(
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