fix: glossar_vorschlag.py schickt keine Zeit-Überschriften ans Modell
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0bf42dee74
commit
5e9a11d0f4
1 changed files with 35 additions and 3 deletions
|
|
@ -15,6 +15,7 @@ from rede_korrigieren import (
|
|||
MODEL, apply_replacements, chat_request, check_ollama, ollama_open, read_glossary,
|
||||
split_chunks,
|
||||
)
|
||||
from vtt2txt import split_segments
|
||||
|
||||
SYSTEM = """Du suchst Hörfehler in der automatischen Abschrift einer deutschen Rede.
|
||||
|
||||
|
|
@ -116,6 +117,11 @@ def model_suggestions(text, model, cache_dir, known):
|
|||
return found
|
||||
|
||||
|
||||
def plain_text(text):
|
||||
"""Running text without time headers ("[00:04:57 - 00:06:04]") of excerpts."""
|
||||
return " ".join(" ".join(body for _, body in split_segments(text)).split())
|
||||
|
||||
|
||||
def contains(words, part):
|
||||
"""Is `part` a contiguous run of `words`?"""
|
||||
return any(words[i:i + len(part)] == part for i in range(len(words) - len(part) + 1))
|
||||
|
|
@ -213,7 +219,7 @@ def parse_args():
|
|||
def main():
|
||||
args = parse_args()
|
||||
|
||||
text = " ".join(read_raw(args.input).split())
|
||||
text = plain_text(read_raw(args.input))
|
||||
if not text:
|
||||
raise SystemExit("Die Eingabedatei ist leer.")
|
||||
|
||||
|
|
@ -234,7 +240,7 @@ def main():
|
|||
|
||||
changes = None
|
||||
if args.korrigiert:
|
||||
corrected = args.korrigiert.read_text(encoding="utf-8")
|
||||
corrected = plain_text(args.korrigiert.read_text(encoding="utf-8"))
|
||||
changes = correction_changes(raw, corrected, replacements, set(suggestions))
|
||||
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue