Commit 47957ad9 by lichenggang

增加类别

parent d2477e8b
...@@ -6,8 +6,8 @@ from collections import Counter ...@@ -6,8 +6,8 @@ from collections import Counter
from utils.log_manager import get_logger from utils.log_manager import get_logger
from utils.robots import dd_send_msg from utils.robots import dd_send_msg
import pandas as pd import pandas as pd
from static_config import *
CATEGORY = ['二极管']
RIGHT_LEVEL = 0.7 RIGHT_LEVEL = 0.7
SEQ_LEVEL = 0.5 SEQ_LEVEL = 0.5
CATE_LEVEL = 0.5 CATE_LEVEL = 0.5
......
...@@ -112,8 +112,8 @@ class DicPredict(BasePredictor): ...@@ -112,8 +112,8 @@ class DicPredict(BasePredictor):
if self.is_catecol(v): if self.is_catecol(v):
temp_pre_model_res[k] = '类别' temp_pre_model_res[k] = '类别'
continue continue
temp_dic_data = {k: list(filter(lambda x: x != self.PLACEHOLDER, dic_data[k])) for k in prob_columns} not_null_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(): for k, v in not_null_dic_data.items():
li_single_pred_res = [] li_single_pred_res = []
for string in v: for string in v:
single_pred_res, probdic = self.get_single_predict(string) single_pred_res, probdic = self.get_single_predict(string)
...@@ -125,8 +125,9 @@ class DicPredict(BasePredictor): ...@@ -125,8 +125,9 @@ class DicPredict(BasePredictor):
prob_param_and_gn_cols = [i for i in temp_pre_model_res if 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] == '型号'] temp_pre_model_res[i] == '参数' or temp_pre_model_res[i] == '型号']
for col in prob_param_and_gn_cols: 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) temp_pre_model_res.pop(col)
model_id_res = { model_id_res = {
'std_result': temp_pre_model_res, 'std_result': temp_pre_model_res,
'ab_result': ab_result, 'ab_result': ab_result,
...@@ -148,7 +149,7 @@ class DicPredict(BasePredictor): ...@@ -148,7 +149,7 @@ class DicPredict(BasePredictor):
if comprehensive_res: if comprehensive_res:
res = { res = {
'std_result': comprehensive_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 return res
......
#!/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):
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