Commit b149fc26 by 陈森彬

增加搜索参数带F/H/K/A/W/KW情况的返回

parent 2037534a
......@@ -134,3 +134,5 @@ split_char = '|,,/ '
special_tuple = ("-",)
special_str = "~!@#$%^&*()_+-*/<>,.。,[]\/"
attr_regex = "F|H|K|A|W|KW"
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import re
from config import unit_map, cast_map, unit_regex, special_tuple, encap_list, temp_map, special_str, encap_regex, \
from config import unit_map, cast_map, unit_regex, special_tuple, attr_regex, temp_map, special_str, encap_regex, \
r_regex, legal_char, split_char
unit_pattern = re.compile('([.a-zA-Z\\-]?)(\d+|\d+[\\\./?]\d+)(' + unit_regex + ')([.a-zA-Z\\-]?)')
attr_pattern = re.compile('(\d+|\.\d+)(' + attr_regex + ')')
r_pattern = re.compile(
'([.a-zA-Z\\-]?)(\d+[' + r_regex + ']\d+|[' + r_regex + ']\d+|\d+[' + r_regex + '])([.a-zA-Z\\-]?)')
encap_pattern = re.compile('(.{0,2})(' + encap_regex + ')(.{0,2})', re.I)
......@@ -299,3 +300,12 @@ def get_unit(unit_list):
if u_str:
unit_str += u_str
return unit_str
def check_attr(kw_info):
res = attr_pattern.findall(kw_info)
if not res:
return False
else:
if res[0][0] and res[0][1] and "." not in res[0][0]:
return True
return False
\ No newline at end of file
......@@ -26,6 +26,7 @@ class StatusCode:
"100002": ("missing param", "缺少输入的参数"),
"100003": ("no qty", "未检测到数量"),
"100004": ("no param or gn", "未检测到参数/型号列"),
"100005": ("not yet included", "中文映射还未收录"),
}
......
......@@ -7,7 +7,7 @@ import tornado.web
import tornado.ioloop
from utils.functions import pre_judge, word_conversion, cut_params, check_param, unit_conversion, get_not_exist_list, \
check_encap, check_temp, check_symbol, check_param_r, check_param_k
check_encap, check_temp, check_symbol, check_param_r, check_param_k ,check_attr
from utils.redis_cli import redis_cli
from predict.kw_predict import KwPredict
......@@ -108,6 +108,7 @@ class UCHandler(tornado.web.RequestHandler):
attrs_list = []
words_list = []
encap_list = []
words2_list = []
old_attrs_list = []
for kw in data_list:
param_data = check_param(kw) # 提取参数
......@@ -127,6 +128,9 @@ class UCHandler(tornado.web.RequestHandler):
attrs_list.append(res_data)
old_attrs_list.append(param)
cut_list = cut_params(kw) # 根据符号,强制切割
for cut_info in cut_list:
if check_attr(cut_info):
words2_list.append(cut_info)
unknown_list = get_not_exist_list(old_attrs_list, cut_list)
for kw_info in unknown_list:
if kw_info:
......@@ -150,6 +154,7 @@ class UCHandler(tornado.web.RequestHandler):
res['words'] = list(set(words_list))
res['attrs'] = list(set(attrs_list))
res['encap'] = list(set(encap_list))
res['words2'] = list(set(words2_list))
print(res)
self.write(res)
......
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