feat: --output Flag für dry-run + Dokumentation aktualisiert
- ingest_V2.py: --output Flag zum Speichern des normalisierten Markdowns - Auto-Output: <originalname>_normalized.md wenn kein --output angegeben - README: --output in Flags-Tabelle + Verwendungsbeispiele ergänzt
This commit is contained in:
@@ -68,6 +68,12 @@ nano .env.ingest # ANTHROPIC_API_KEY eintragen
|
|||||||
```bash
|
```bash
|
||||||
python ingest_V2.py file ~/Downloads/fremdes_cv.pdf
|
python ingest_V2.py file ~/Downloads/fremdes_cv.pdf
|
||||||
python ingest_V2.py file ~/Desktop/scan.png --dry-run
|
python ingest_V2.py file ~/Desktop/scan.png --dry-run
|
||||||
|
|
||||||
|
# Dry-Run + normalisiertes Markdown automatisch speichern (<dateiname>_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 file ~/templates/ausgefuellt/mein_cv.md --no-normalize
|
||||||
python ingest_V2.py dir ~/Dokumente/bewerbungsunterlagen/ --force
|
python ingest_V2.py dir ~/Dokumente/bewerbungsunterlagen/ --force
|
||||||
python ingest_V2.py watch ~/Desktop/scan-eingang/
|
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 |
|
| `--force` | Bestehende Chunks überschreiben |
|
||||||
| `--no-normalize` | KI-Normalisierung überspringen |
|
| `--no-normalize` | KI-Normalisierung überspringen |
|
||||||
| `--dry-run` | Nur extrahieren + normalisieren, nicht in DB speichern |
|
| `--dry-run` | Nur extrahieren + normalisieren, nicht in DB speichern |
|
||||||
|
| `--output <pfad>` | Normalisiertes Markdown als Datei speichern (nur mit `--dry-run`) |
|
||||||
| `--quality-min 0.5` | Mindest-Qualitäts-Score (0.0–1.0, Standard: 0.0) |
|
| `--quality-min 0.5` | Mindest-Qualitäts-Score (0.0–1.0, Standard: 0.0) |
|
||||||
|
|
||||||
### KI-Normalisierung (`normalizer.py`)
|
### KI-Normalisierung (`normalizer.py`)
|
||||||
|
|||||||
+16
-1
@@ -174,6 +174,7 @@ def ingest_file(
|
|||||||
normalize_doc: bool = True,
|
normalize_doc: bool = True,
|
||||||
dry_run: bool = False,
|
dry_run: bool = False,
|
||||||
quality_min: float = 0.0,
|
quality_min: float = 0.0,
|
||||||
|
output_path: str = "",
|
||||||
) -> bool:
|
) -> bool:
|
||||||
path = Path(file_path).resolve()
|
path = Path(file_path).resolve()
|
||||||
|
|
||||||
@@ -258,6 +259,16 @@ def ingest_file(
|
|||||||
print("\n" + "─" * 60)
|
print("\n" + "─" * 60)
|
||||||
print(text_to_index[:600] + ("..." if len(text_to_index) > 600 else ""))
|
print(text_to_index[:600] + ("..." if len(text_to_index) > 600 else ""))
|
||||||
print("─" * 60)
|
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: <originalname>_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
|
return True
|
||||||
|
|
||||||
# ── 5. Datenbank ─────────────────────────────────────────────────────────
|
# ── 5. Datenbank ─────────────────────────────────────────────────────────
|
||||||
@@ -445,6 +456,8 @@ Beispiele:
|
|||||||
help="Mindest-Qualitäts-Score (Standard: 0.0)")
|
help="Mindest-Qualitäts-Score (Standard: 0.0)")
|
||||||
common.add_argument("--dry-run", action="store_true",
|
common.add_argument("--dry-run", action="store_true",
|
||||||
help="Nur extrahieren + normalisieren, nicht speichern")
|
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 = sub.add_parser("file", parents=[common], help="Einzelne Datei importieren")
|
||||||
pf.add_argument("path", help="Pfad zur Datei")
|
pf.add_argument("path", help="Pfad zur Datei")
|
||||||
@@ -470,9 +483,11 @@ def main():
|
|||||||
dry_run = getattr(args, "dry_run", False)
|
dry_run = getattr(args, "dry_run", False)
|
||||||
quality_min = getattr(args, "quality_min", 0.0)
|
quality_min = getattr(args, "quality_min", 0.0)
|
||||||
|
|
||||||
|
output_path = getattr(args, "output", "") or ""
|
||||||
|
|
||||||
if args.command == "file":
|
if args.command == "file":
|
||||||
ingest_file(args.path, force=force, normalize_doc=do_normalize,
|
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":
|
elif args.command == "dir":
|
||||||
ingest_directory(args.path, force=force, normalize_doc=do_normalize,
|
ingest_directory(args.path, force=force, normalize_doc=do_normalize,
|
||||||
dry_run=dry_run, quality_min=quality_min)
|
dry_run=dry_run, quality_min=quality_min)
|
||||||
|
|||||||
Reference in New Issue
Block a user