"""Diagnostic for the keyword-mode misses (not part of the main table, which keeps defaults). Runs the six questions in keyword mode with the default drop_tokens_threshold (1) and with 50. Prints `found` (matching chunks) and the rank of the expected page among the first 5 pages.""" from common import hit_rank, pages, questions from ts_query import search, urls print("keyword mode, per_page 50 | found = matching chunks | rank = expected page among first 5 pages (- = miss)") for thr in (1, 50): print(f"\ndrop_tokens_threshold {thr}" + (" (default)" if thr == 1 else "")) ok = 0 for q in questions(): res = search(q["question"], extra={"drop_tokens_threshold": thr}) r = hit_rank(urls(res), q["expected_url_contains"]) ok += r is not None print(f" {q['question'][:62]:<64} found {res['found']:>3} rank {r or '-'}") print(f" expected page in top 5: {ok}/6") print("\ntypo case: the correct spelling vs the misspelling, default threshold 1") for text in ("cancel crawl job", "cancle crawl job"): res = search(text) print(f" '{text}': found {res['found']} | first pages {pages(urls(res))[:3]}")