YOKPilot3 / guards.py
mfirat007's picture
Upload 98 files
eff511c
Raw
History Blame Contribute Delete
1.08 kB
from utils import normalize_for_search
AUTHORSHIP_TERMS = {
"yazdi", "yazan", "yazilmis", "yazilmistir", "yazar",
"yazari", "hazirladi", "hazirlandi", "hazirlayan",
"hazirlanmis", "hazirlanmistir", "duzenleyen", "kaleme",
"muellif",
}
AUTHORSHIP_CONTEXT_TERMS = {
"kanun", "kanunu", "2547", "metin", "yasa", "yasayi",
}
KNOWN_FALSE_AUTHOR_TERMS = {
"omer", "ilhan", "prof",
}
def is_unsupported_metadata_question(question: str) -> bool:
"""Detect source-external authorship/preparer questions that must not be guessed."""
q = normalize_for_search(question)
if not q:
return False
tokens = set(q.split())
if tokens & KNOWN_FALSE_AUTHOR_TERMS:
return True
asks_person = "kim" in tokens or "kimin" in tokens or "kisi" in tokens or "kisinin" in tokens
has_authorship = bool(tokens & AUTHORSHIP_TERMS) or "kaleme alan" in q or "tarafindan hazirlan" in q
has_context = bool(tokens & AUTHORSHIP_CONTEXT_TERMS)
return asks_person and has_authorship and has_context