Commit 036e5d48 by 陈森彬

增加单对带K的参数转换

parent 0065abee
Showing with 34 additions and 6 deletions
......@@ -269,6 +269,30 @@ def check_param_r(kw):
return check_res
def check_param_k(kw):
"""
确认是不是单独K结尾
:param kw:
:return:
"""
if "K" not in kw.upper():
return False
else:
check_res = kw.upper().split("K")
if check_res[1] and check_res[1] not in split_char:
return False
if check_res[0].isdigit() or "." in check_res[0]:
if "." in check_res[0]:
res = str(delete_extra_zero(float(check_res[0]) * 1000)) + "Ω"
else:
res = str(int(check_res[0]) * 1000) + "Ω"
else:
return False
return res
def get_unit(unit_list):
unit_str = ""
for u_str in unit_list:
......
......@@ -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_encap, check_temp, check_symbol, check_param_r, check_param_k
from utils.redis_cli import redis_cli
from predict.kw_predict import KwPredict
......@@ -122,20 +122,24 @@ class UCHandler(tornado.web.RequestHandler):
attrs_list.append(res_data)
old_attrs_list.append(param)
else:
res_data = unit_conversion(unit_res, param)
res_data = unit_conversion(unit_res, param) # 没有中文的参数转换
if res_data:
attrs_list.append(res_data)
old_attrs_list.append(param)
cut_list = cut_params(kw)
cut_list = cut_params(kw) # 根据符号,强制切割
unknown_list = get_not_exist_list(old_attrs_list, cut_list)
for kw_info in unknown_list:
if kw_info:
if check_temp(kw_info):
if check_temp(kw_info): # 确认是不是温漂系数
attrs_list.append(kw_info)
elif check_param_r(kw_info):
elif check_param_r(kw_info): # 确认是不是简写R/r
attrs_list.append(check_param_r(kw_info)[0])
else:
encap_res = check_encap(kw_info)
k_res = check_param_k(kw_info) # 确认是不是单独K结尾
if k_res:
attrs_list.append(k_res)
continue
encap_res = check_encap(kw_info) # 确认是不是封装
if encap_res:
encap_list.append(encap_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