increase sample size to 50 and update write_result function to include additional document fields

This commit is contained in:
Steven Tischer
2026-06-12 20:05:27 +02:00
parent 270cc0096d
commit 815797dfd6
@@ -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.")