增加ocr值的判断条件, 如果出现AL以外的字母和小数点后有两位小数的字符串会过滤掉
This commit is contained in:
parent
6f257ddb4e
commit
6fd4139c0a
@ -393,15 +393,26 @@ class Kangda:
|
|||||||
# 定义正则表达式模式
|
# 定义正则表达式模式
|
||||||
temperature_pattern = re.compile(r'^[+-]?\d+\.\d+C$') # 匹配温度数据
|
temperature_pattern = re.compile(r'^[+-]?\d+\.\d+C$') # 匹配温度数据
|
||||||
al_pattern = re.compile(r'^AL\d+$') # 匹配AL后跟数字
|
al_pattern = re.compile(r'^AL\d+$') # 匹配AL后跟数字
|
||||||
|
|
||||||
|
al_pattern_not = re.compile(r'[^AL]')
|
||||||
|
|
||||||
cn_pattern = re.compile(r'[\u4e00-\u9fff]') # 判断是否有中文
|
cn_pattern = re.compile(r'[\u4e00-\u9fff]') # 判断是否有中文
|
||||||
|
|
||||||
|
# 判断是否含有小数点, xiaoshudian后有两位小数的返回True
|
||||||
|
float_pattern = re.compile(r'^\d*\.\d{2,}$') # 匹配纯小数(如 "3.14")
|
||||||
|
|
||||||
start = self.config["temperature_range"]["start"]
|
start = self.config["temperature_range"]["start"]
|
||||||
end = self.config["temperature_range"]["end"]
|
end = self.config["temperature_range"]["end"]
|
||||||
|
|
||||||
status = list()
|
status = list()
|
||||||
|
|
||||||
for value in values:
|
for value in values:
|
||||||
if cn_pattern.match(value):
|
# 字符串中含有AL以外的字母.
|
||||||
|
if bool(al_pattern_not.search(value)):
|
||||||
|
status.append(TemperatureStatus.CN)
|
||||||
|
elif bool(float_pattern.fullmatch(value)):
|
||||||
|
status.append(TemperatureStatus.CN)
|
||||||
|
elif cn_pattern.match(value):
|
||||||
status.append(TemperatureStatus.CN)
|
status.append(TemperatureStatus.CN)
|
||||||
|
|
||||||
# ocr字符长度小于3
|
# ocr字符长度小于3
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user