mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-22 21:31:59 +00:00
e15e94f93e
- 新增口径结构化语义定义、分批解析与 SQL 生成管道(semantic / semantic_import / semantic_sql) - 支持起草断点续跑恢复、指标自动匹配对齐与存量口径语义迁移面板(MigrationPanel / SemanticPanel) - 口径草稿与变更流程接入候选本体边提议、审阅确认与一键修改保护,同步更新可移植 SQLite 基线校验
19 lines
814 B
Python
19 lines
814 B
Python
"""Deterministic candidate retrieval. Matching a name is not permission to execute a metric."""
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
from collections.abc import Iterable
|
|
|
|
from app.ledger.semantic import mention
|
|
|
|
|
|
def score(question: str, name: str, aliases: Iterable[str] = ()) -> int:
|
|
terms = [name, *aliases]
|
|
exact = [len(term) for term in terms if isinstance(term, str) and mention(question, term)]
|
|
if exact:
|
|
return 100 + max(exact)
|
|
# OEE/RTY/TEEP are discoverable even when the old metric only has a qualified display name.
|
|
# This only produces candidates; it never selects between their different business formulas.
|
|
tokens = set(re.findall(r"(?<![A-Za-z])[A-Z][A-Z0-9]{1,9}(?![A-Za-z])", name))
|
|
return 1 if any(mention(question, token) for token in tokens) else 0
|