Commit 304cf454 by lzzzzl

新增识别序号列

parent e9424909
No preview for this file type
......@@ -7,6 +7,7 @@ from protobuf import classify_pb2_grpc
from utils.config import model_config
from utils.predic_fac import PredictorFac
from utils.log_manager import get_logger
from utils.excel_manager import read_from_excel
log_server = get_logger('server')
......@@ -40,5 +41,8 @@ def serve():
if __name__ == '__main__':
serve()
# print(Classify().fac_test_predic('lm358'))
# serve()
data = read_from_excel('DZ0901_V1.4_BOM.xlsx', 'DZ0901_V1.3BOM清单')
print(data)
print(Classify().fac_test_predic(data))
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from predict.base_handler import BasePredictor
from utils.excel_manager import read_from_excel
order_list = ['序号']
class LiPredict(BasePredictor):
pass
\ No newline at end of file
def predict(self, key):
if len(key) > 0:
self.order_predict(key[0])
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)
#!/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
......@@ -15,7 +15,7 @@ class PredictorFac():
def _get_predictor(self, data):
if isinstance(data, str):
return self.kw_predictor
elif isinstance(data, list):
elif isinstance(data, dict):
return self.list_predictor
def predic(self, data):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment