From 815797dfd6a5b5c2922e9748e0646479365f0ca2 Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Fri, 12 Jun 2026 20:05:27 +0200 Subject: [PATCH] increase sample size to 50 and update write_result function to include additional document fields --- .../news_ident_person/llm_classify_news.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/llm_evaluations/news_ident_person/llm_classify_news.py b/llm_evaluations/news_ident_person/llm_classify_news.py index 8da99c54..b5d6ca4b 100644 --- a/llm_evaluations/news_ident_person/llm_classify_news.py +++ b/llm_evaluations/news_ident_person/llm_classify_news.py @@ -15,7 +15,7 @@ ES_HEADERS = { "Content-Type": "application/json", } -SAMPLE_SIZE = 30 +SAMPLE_SIZE = 50 RANDOM_SEED = 42 SCROLL_PAGE_SIZE = 1000 @@ -131,14 +131,23 @@ def parse_label(answer): return None -def write_result(news_id, label): - safe_name = news_id.replace("/", "_") - file_path = os.path.join(OUTPUT_FOLDER, f"{safe_name}.json") +def write_result(document, label): + source = document.get("_source", {}) + news_id = document.get("_id") result = { "_id": news_id, + "maintitle": source.get("maintitle"), + "subtitle": source.get("subtitle"), + "author": source.get("author"), + "date": source.get("date"), + "full_content": source.get("full_content"), "llm_label": label, + "human_label": [], } + + safe_name = news_id.replace("/", "_") + file_path = os.path.join(OUTPUT_FOLDER, f"{safe_name}.json") with open(file_path, "w", encoding="utf-8") as output_file: json.dump(result, output_file, ensure_ascii=False, indent=2) @@ -176,7 +185,7 @@ def main(): label = parse_label(answer) print(f"{news_id}: LLM-Antwort={answer!r} -> label={label}") - write_result(news_id, label) + write_result(document, label) print(f"Fertig. Ergebnisse in '{OUTPUT_FOLDER}/' gespeichert.")