Files
Cognitive_Agent/src/cognitive_agent/application/schedule_intent.py
T

26 lines
1.0 KiB
Python

"""Narrow detection of temporal scene needs; never authorizes execution."""
from __future__ import annotations
import re
_TEMPORAL = re.compile(
r"动态|循环|分阶段|随时间|交替|轮流|每隔|预热|预冷|"
r"(?:秒|分钟|分|小时)(?:钟)?(?:后|再)|持续.{0,8}(?:秒|分钟|小时)"
)
_STOP = re.compile(
r"^(?:请|帮我|立即|马上|先)?(?:停止|停下|结束|取消|关闭)"
r"(?:当前|正在执行的|正在运行的|这个|该)?(?:座椅|空调|功能)?(?:动态|循环|分阶段|时间轴|定时)"
r"(?:座椅|空调|功能)?(?:模式|编排|任务)?[。!!\s]*$"
)
def needs_mode_schedule(text: str) -> bool:
# HVAC recirculation is a stable device enum, not a timed repetition.
normalized = re.sub(r"内外循环|内循环|外循环|自动循环|新风循环|循环风", "空气循环状态", text)
normalized = normalized.replace("空气循环状态", "空气状态")
return bool(_TEMPORAL.search(normalized))
def is_schedule_stop(text: str) -> bool:
return bool(_STOP.fullmatch(text.strip()))