Commit 361d96f2 by lichenggang

位号列预测

parent 239f8b38
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import grpc
from protobuf import classify_pb2
from protobuf import classify_pb2_grpc
import pandas as pd
import json
import pandas as pd
def get_test_data():
df=pd.read_excel(r'C:\Users\ICHUNT\Desktop\bomlist\DZ0901_V1.4_BOM.xlsx',header=None)
df.fillna(' ', inplace=True)
df = pd.read_excel(r'C:\Users\ICHUNT\Desktop\bomlist\150套标准.xlsx', header=None)
df.fillna('?', inplace=True)
dic_dft = df.to_dict(orient='list')
print(dic_dft)
a=r'{"1":["?","10uF ±10% 16V","0603 ±20% 10V","3.9nF ±10% "],"2":["AC0201FR-0710KL","?","?","?"],"3":["?","?","?","0402"],"4":[2500,3000,1800,3000],"5":["?","?","?","?"],"6":["?","?","?","?"]}'
return json.dumps(dic_dft)
def run():
# 连接 rpc 服务器
# channel = grpc.insecure_channel('192.168.2.232:50051')
channel = grpc.insecure_channel('localhost:50051')
# 调用 rpc 服务
# 调用 rpc 服务C:\Users\ICHUNT\Pictures\Saved Pictures\1.png
stub = classify_pb2_grpc.classifyStub(channel)
test = get_test_data()
response = stub.Classify(classify_pb2.ClassifyRequest(keyword=test))
print("Classify client received: " + response.message)
if __name__ == '__main__':
run()
# !/usr/bin/env python
# -*- coding:utf-8 -*-
# import requests
# d={"1":["LIEXIN001","STM32L4R9ZIY6TR"],"2":[100,200],"3":["?","?"],"4":["?","?"],"5":["?","?"],"6":["?","?"]}
# js = json.dumps(d)
# # b=requests.post('http://192.168.2.232:50052/dict', data=js).text
# b=requests.post('http://127.0.0.1:50052/dict', data=js).text
# b=json.loads(b)
# print(b)
......@@ -12,7 +12,7 @@ RIGHT_LEVEL = 0.7
SEQ_LEVEL = 0.5
CATE_LEVEL = 0.5
MULTI_SAME_LEVEL = 3
REF_LEVEL = 0.5
class BasePredictor:
'''
......@@ -164,6 +164,16 @@ class BasePredictor:
comprehensive_res[col] = std_name
return comprehensive_res
@classmethod
def is_ref(self, data):
"""
位号列预测
"""
pat = re.compile(r'[CJRULX][1-9]{1,3}')
count = 0
for i in data:
if pat.findall(str(i)):
count += 1
return round(count / len(data), 3) >= REF_LEVEL or False
if __name__ == "__main__":
print(BasePredictor.is_num([3400.0, 5920.0, 4849.0, 2544.0, 3270.0, 52751.0, 2031.0, 5302.0, 726.0, 1247.0, 2472.0, 689.0, 6049.0, 26796.0, 6164.0, 1605.0, 4346.0, 640.0, 960.0, 960.0, 320.0, 160.0, 860.0, 160.0, 320.0, 3183.0, 10151.0, 640.0, 130.0, 1237.0, 800.0, 960.0, 3740.0, 17701.0, 2146.0, 1280.0, 160.0, 1120.0, 160.0, 480.0, 960.0, 480.0, 160.0, 4717.0, 160.0, 160.0, 160.0, 640.0, 160.0, 320.0, 160.0, 160.0, 800.0, 800.0, 480.0, 1600.0, 155.0, 960.0, 320.0, 944.0, 160.0, 160.0, 1280.0, 1852.0, 7680.0, 7680.0, 2880.0, 160.0, 224.0, 480.0, 480.0, 640.0, 160.0, 640.0, 320.0, 1760.0, 640.0, 480.0, 960.0, 160.0, 160.0, 160.0, 160.0, 1920.0, 160.0, 5600.0, 480.0, 2560.0, 160.0, 160.0, 160.0, 160.0, 160.0, 1280.0, 160.0, 160.0, 160.0, 160.0, 160.0, 320.0, 0.0, 160.0, 160.0]))
......@@ -97,6 +97,9 @@ class DicPredict(BasePredictor):
if self.is_num(no_null_v):
temp_pre_model_res[k] = '数量'
continue
if self.is_ref(no_null_v):
ab_result[k] = '位号'
continue
if bol:
prob_columns.append(k)
......
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