hodnotenie testov: meno len ako súvislé slová, užšie odmietnutie, stránky bez nového tokenu končia

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ján Pták 2026-11-24 18:34:42 +01:00
parent cf2c3c0390
commit 4a0dc506d0
2 changed files with 11 additions and 7 deletions

View File

@ -115,7 +115,7 @@ def run_case(case: dict, base: str) -> dict:
more = ask(base, "áno", case["engine"], token)
except Exception:
break
token = (more.get("conversation_context") or {}).get("token") or token
token = (more.get("conversation_context") or {}).get("token") # no new token: the list has no further page
result = {**result, "answer": (result.get("answer") or "").replace(MORE, "") + "\n\n" + (more.get("answer") or ""),
"source_urls": list(dict.fromkeys([*(result.get("source_urls") or []), *(more.get("source_urls") or [])]))}
pages += 1

View File

@ -25,25 +25,29 @@ REFUSAL = re.compile(r"nie je uveden|nie je v podkladoch|v podkladoch nie|taky u
r"neexist|nie je zaznamenan|nie su zaznamenan|nemozem|neviem|ziadn|nie je dostupn|upresn|ktor\w+ mysli|"
r"nie je mozne|nepotvrdzujem|neuvadza|nie je zname|nie je evidovan|odpovedam len|nie je doloz|"
r"skontroluj meno|uved cele meno|nie je isté|nie je iste|nema v podkladoch|nemaju v podkladoch|"
r"klucove slovo [^.;]{1,60}? nema\b|\bnemaju\b|nespomina|nesplna|v podkladoch nie su")
r"klucove slovo [^.;]{1,60}? nema\b|\bnemaju\s+spolocn|\bspolocn\w*(?:\s+\w+){0,4}\s+nemaju\b|nespomina|nesplna|"
r"v podkladoch nie su")
def fold(text: str | None) -> str:
return " ".join(unicodedata.normalize("NFKD", text or "").encode("ascii", "ignore").decode().lower().split())
NAME = re.compile(r"^[A-ZÁ-Ž][^\W\d_]+(?:\s+[A-ZÁ-Ž][^\W\d_]+){1,2}$")
def is_name(phrase: str) -> bool:
"""Two or three words, each capitalized and only letters ("Martin Šarišský", "Denis Le Thanh")."""
words = phrase.split()
return 2 <= len(words) <= 3 and all(w.isalpha() and w[0].isupper() for w in words)
def contains(phrase: str, text: str) -> bool:
"""The phrase in the folded text; a person's name also in another case ("Martina Šarišského" for
"Martin Šarišský"): every word's stem starts a word of the text."""
"Martin Šarišský"): the words' stems next to each other, in order (never words of two other people)."""
if fold(phrase) in text:
return True
if not NAME.match(phrase.strip()):
if not is_name(phrase.strip()):
return False
stems = [fold(w)[:max(4, len(w) - 2)] for w in phrase.split()]
return all(re.search(rf"\b{re.escape(stem)}", text) for stem in stems)
stems = [fold(w)[:max(4, len(fold(w)) - 2)] for w in phrase.split()]
return bool(re.search(r"\b" + r"\w*\s+".join(re.escape(stem) for stem in stems) + r"\w*\b", text))
def check(case: dict, result: dict) -> dict: