Files
cookbook/summarize_texts.py

18 lines
547 B
Python

import os
import json
TXT_DIR = '/home/maxi/Projekt/wtc.waiswuaschd.de/data/extracted_texts'
files = sorted(os.listdir(TXT_DIR))
summary = {}
for f in files:
path = os.path.join(TXT_DIR, f)
with open(path, 'r', encoding='utf-8', errors='ignore') as fp:
content = fp.read()
summary[f] = content
with open('/home/maxi/Projekt/wtc.waiswuaschd.de/data/recipes_summary.json', 'w', encoding='utf-8') as fp:
json.dump(summary, fp, ensure_ascii=False, indent=2)
print("Saved recipes_summary.json with", len(summary), "files.")