nl2sql-copilot / nl2sql /ambiguity_detector.py
Melika Kheirieh
style: format code with ruff
105e019
raw
history blame
473 Bytes
import re
class AmbiguityDetector:
"""Lightweight AmbiSQL-style ambiguity detection."""
AMBIGUOUS_TERMS = ["recent", "top", "name", "rank", "latest"]
def detect(self, query: str, schema_preview: str) -> list[str]:
hits = []
q_lower = query.lower()
for term in self.AMBIGUOUS_TERMS:
if re.search(rf"\b{term}\b", q_lower):
hits.append(f"The term '{term}' is ambiguous in this query.'")
return hits