File size: 473 Bytes
570f7bd
 
c1bc4eb
570f7bd
 
 
 
 
c1bc4eb
570f7bd
 
 
 
 
 
c1bc4eb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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