Commit ea9d33ab by 陈森彬

增加封装和温漂系数的识别

parent b94926d2
......@@ -100,6 +100,25 @@ cast_map = {
'瓦': 'W',
}
encap_list = ["0030", "008004", "01005", "015008", "0201", "02016", "0202", "0204", "03015", "03019", "0302", "0303",
"0306", "0402", "0404", "0405", "0406", "0502", "0503", "0504", "0505", "0508",
"0602", "0603", "0604", "0605", "0606", "0612", "0704", "0707", "0709", "0803", "0804", "0805", "0806",
"0815", "0830", "0905", "0909", "1003", "1005", "1006", "1007", "1008", "1010", "1012",
"1020", "1106", "1111", "1113", "1204", "1205", "1206", "1207", "1208", "1209", "1210", "1211", "1212",
"1213", "1218", "1225", "1230", "1246", "1305", "1410", "1411", "1412", "1414", "1505", "1507",
"1510", "1512", "1515", "1530", "1606", "1608", "1611", "1612", "1616", "1625", "1708", "1715", "1805",
"1806", "1807", "1808", "1810", "1812", "1816", "1825", "1835", "1913", "1916", "1919", "2005",
"2008", "2010", "2015", "2016", "2018", "2020", "2023", "2043", "2211", "2214", "2215", "2218", "2220",
"2225", "2304", "2312", "2323", "2325", "2410", "2414", "2416", "2420", "2423", "2424", "2512",
"2520", "2525", "2615", "2616", "2706", "2709", "2711", "2721", "2727", "2728", "2812", "2820", "2824",
"2825", "2828", "2830", "2910", "2913", "2915", "2917", "2920", "2924", "3010", "3015", "3017",
"3022", "3024", "3025", "3040", "3131", "3225", "3226", "3312", "3318", "3333", "3640", "3838", "3920",
"3925", "3931", "4030", "4032", "4122", "4520", "4823", "4850", "5040", "5329", "5829", "5929",
"6028", "6030", "6031", "6039", "6054", "6560"]
temp_map = ["C0G", "NP0", "COG", "NPO", "X7R", "X5R", "Y5V", "X6S", "X7S", "X7T", "SL", "U2J", "UJ", "X7U", "X8R",
"Z5U", "C0H", "COH", "U2K", "X6T", "X8G", "X8L", "Y5R", "Y5U", "ZLM"]
unit_regex = "μΩ|uΩ|mΩ|Ω|kΩ|KΩ|MΩ|GΩ|TΩ|pF|PF|Pf|pf|nF|NF|Nf|nf|µF|μF|uF|UF|Uf|uf|mF|MF|Mf|mf|F|pH|Ph|PH|ph|nH|µH|UH|μh|uh|Uh|uH|mH|Mh|MH|mh|H|mA|A|a|V|v|kV|Kv|kv|KV|W|w|kW|kw|KW|Kw|%|毫欧|欧姆|欧|千欧|兆欧|伏特|伏|千伏|瓦特|瓦"
special_tuple = ("-",)
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import re
from config import unit_map, cast_map, unit_regex, special_tuple
from config import unit_map, cast_map, unit_regex, special_tuple, encap_list, temp_map
unit_pattern = re.compile('(\d+|\d+[\\\./?]\d+)(' + unit_regex + ')([.a-zA-Z\\-]?)')
......@@ -60,7 +60,6 @@ def check_param(kw):
:return:
"""
check_res = unit_pattern.findall(kw)
print(check_res)
if len(check_res) < 2:
check_res = [kw]
else:
......@@ -178,6 +177,28 @@ def get_not_exist_list(attrs_list, cut_list):
return not_exist_list
def check_encap(kw):
"""
确认是不是封装
:param kw:
:return:
"""
if kw in encap_list:
return True
return False
def check_temp(kw):
"""
确认是不是温漂系数
:param kw:
:return:
"""
if kw in temp_map:
return True
return False
def get_unit(unit_list):
unit_str = ""
for u_str in unit_list:
......
......@@ -6,7 +6,8 @@ from urllib.parse import unquote
import tornado.web
import tornado.ioloop
from utils.functions import pre_judge, word_conversion, cut_params, check_param, unit_conversion, get_not_exist_list
from utils.functions import pre_judge, word_conversion, cut_params, check_param, unit_conversion, get_not_exist_list, \
check_encap, check_temp
from utils.redis_cli import redis_cli
from predict.kw_predict import KwPredict
......@@ -91,6 +92,7 @@ class UCHandler(tornado.web.RequestHandler):
super().__init__(*args, **kwargs)
self.predic = KwPredict('validSingle')
self.w_par = re.compile(r'[\u4e00-\u9fa5]+')
self.encap_par = re.compile(r'\d+')
self.unit_pattern = re.compile('([^0-9±/,.])')
async def post(self):
......@@ -123,12 +125,21 @@ class UCHandler(tornado.web.RequestHandler):
old_attrs_list.append(param)
cut_list = cut_params(kw)
unknown_list = get_not_exist_list(old_attrs_list, cut_list)
print("unknown", unknown_list)
for kw_info in unknown_list:
if check_temp(kw_info):
attrs_list.append(kw_info)
else:
encap_res = self.encap_par.findall(kw_info)
if encap_res:
if check_encap(encap_res[0]):
encap_list.append(encap_res[0])
continue
words_list.append(kw_info)
res['status'] = 1
res['words'] = words_list
res['attrs'] = attrs_list
res['encap'] = encap_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