From 009e9b7badfbeb28c37c898447827c557d0a29f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Fr=C3=B6hlich?= Date: Wed, 29 Apr 2026 11:08:26 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20--output=20Flag=20f=C3=BCr=20dry-run=20?= =?UTF-8?q?+=20Dokumentation=20aktualisiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ingest_V2.py: --output Flag zum Speichern des normalisierten Markdowns - Auto-Output: _normalized.md wenn kein --output angegeben - README: --output in Flags-Tabelle + Verwendungsbeispiele ergänzt --- README.md | 7 +++++++ ingest_V2.py | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 862129b..b781cf3 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,12 @@ nano .env.ingest # ANTHROPIC_API_KEY eintragen ```bash python ingest_V2.py file ~/Downloads/fremdes_cv.pdf python ingest_V2.py file ~/Desktop/scan.png --dry-run + +# Dry-Run + normalisiertes Markdown automatisch speichern (_normalized.md) +python ingest_V2.py file ~/Downloads/cv.pdf --dry-run + +# Dry-Run + normalisiertes Markdown in bestimmte Datei speichern +python ingest_V2.py file ~/Downloads/cv.pdf --dry-run --output ~/Desktop/cv_normalisiert.md python ingest_V2.py file ~/templates/ausgefuellt/mein_cv.md --no-normalize python ingest_V2.py dir ~/Dokumente/bewerbungsunterlagen/ --force python ingest_V2.py watch ~/Desktop/scan-eingang/ @@ -101,6 +107,7 @@ python ingest_V2.py delete "Arbeitszeugnis Sopra Financial Technology GmbH.pdf" | `--force` | Bestehende Chunks überschreiben | | `--no-normalize` | KI-Normalisierung überspringen | | `--dry-run` | Nur extrahieren + normalisieren, nicht in DB speichern | +| `--output ` | Normalisiertes Markdown als Datei speichern (nur mit `--dry-run`) | | `--quality-min 0.5` | Mindest-Qualitäts-Score (0.0–1.0, Standard: 0.0) | ### KI-Normalisierung (`normalizer.py`) diff --git a/ingest_V2.py b/ingest_V2.py index 8363752..ca72602 100644 --- a/ingest_V2.py +++ b/ingest_V2.py @@ -174,6 +174,7 @@ def ingest_file( normalize_doc: bool = True, dry_run: bool = False, quality_min: float = 0.0, + output_path: str = "", ) -> bool: path = Path(file_path).resolve() @@ -258,6 +259,16 @@ def ingest_file( print("\n" + "─" * 60) print(text_to_index[:600] + ("..." if len(text_to_index) > 600 else "")) print("─" * 60) + # ── Output in Datei schreiben ──────────────────────────────────────── + if output_path: + out = Path(output_path) + out.write_text(text_to_index, encoding="utf-8") + print(f" 💾 Gespeichert: {out}") + elif norm["was_normalized"]: + # Auto-Output: _normalized.md im gleichen Verzeichnis + auto_out = path.parent / (path.stem + "_normalized.md") + auto_out.write_text(text_to_index, encoding="utf-8") + print(f" 💾 Auto-gespeichert: {auto_out}") return True # ── 5. Datenbank ───────────────────────────────────────────────────────── @@ -445,6 +456,8 @@ Beispiele: help="Mindest-Qualitäts-Score (Standard: 0.0)") common.add_argument("--dry-run", action="store_true", help="Nur extrahieren + normalisieren, nicht speichern") + common.add_argument("--output", metavar="PFAD", + help="Normalisiertes Markdown in diese Datei schreiben (nur bei --dry-run)") pf = sub.add_parser("file", parents=[common], help="Einzelne Datei importieren") pf.add_argument("path", help="Pfad zur Datei") @@ -470,9 +483,11 @@ def main(): dry_run = getattr(args, "dry_run", False) quality_min = getattr(args, "quality_min", 0.0) + output_path = getattr(args, "output", "") or "" + if args.command == "file": ingest_file(args.path, force=force, normalize_doc=do_normalize, - dry_run=dry_run, quality_min=quality_min) + dry_run=dry_run, quality_min=quality_min, output_path=output_path) elif args.command == "dir": ingest_directory(args.path, force=force, normalize_doc=do_normalize, dry_run=dry_run, quality_min=quality_min)