feat: englische Reden korrigieren (-l en)
- Prompts je Sprache (PROMPTS): Korrektur, Absatzgliederung, Teilen, Glossar-Hinweis; Englisch mit Prüfmarke [check: …] und Entfernen der Sprecherwechsel-Marken „>>“ - -l gilt jetzt auch mit -i (Sprache der Rede, Standard de); mit -u wird die Sprache des Original-Audios erkannt; nicht unterstützte Sprachen werden abgelehnt - Live geprüft mit 0LmCveTM788 (Mearsheimer): 12 Änderungen, u. a. richtig „Vermont“ → „Wehrmacht“, aber falsch „February 25th“ → „24th“ – der Änderungsbericht zeigt es Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
95bdc660ca
commit
fb9201b721
1 changed files with 170 additions and 27 deletions
|
|
@ -417,6 +417,63 @@ def test_main_url_output_option_and_kept_raw_text(from_url, tmp_path, monkeypatc
|
|||
assert "bleibt unverändert" in capsys.readouterr().out
|
||||
|
||||
|
||||
def recording_model(monkeypatch):
|
||||
"""Fake correction and paragraph models that record their system prompts."""
|
||||
systems = []
|
||||
|
||||
def correct(chunk, index, system):
|
||||
systems.append(system)
|
||||
return chunk.strip()
|
||||
|
||||
def find(sentences, first, system):
|
||||
systems.append(system)
|
||||
return set()
|
||||
|
||||
monkeypatch.setattr(rk, "correct_chunk", correct)
|
||||
monkeypatch.setattr(rk, "find_paragraph_starts", find)
|
||||
return systems
|
||||
|
||||
|
||||
def test_build_system_english():
|
||||
system = rk.build_system(["Mearsheimer"], "en")
|
||||
assert system.startswith(rk.SYSTEM_EN)
|
||||
assert "Glossary:" in system and "- Mearsheimer" in system
|
||||
|
||||
|
||||
def test_main_english_prompts(sample_copy, monkeypatch, capsys):
|
||||
systems = recording_model(monkeypatch)
|
||||
run_main(monkeypatch, "-i", sample_copy, "-l", "en-US")
|
||||
assert systems[0] == rk.SYSTEM_EN
|
||||
assert rk.PARAGRAPH_SYSTEM_EN in systems
|
||||
assert "Sprache der Rede: en" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_main_default_language_is_german(sample_copy, monkeypatch):
|
||||
systems = recording_model(monkeypatch)
|
||||
run_main(monkeypatch, "-i", sample_copy)
|
||||
assert systems[0] == rk.SYSTEM
|
||||
assert rk.PARAGRAPH_SYSTEM in systems
|
||||
|
||||
|
||||
@pytest.mark.parametrize("language, expected", [("en-US", "SYSTEM_EN"), ("de", "SYSTEM")])
|
||||
def test_main_url_language_from_video(
|
||||
fake_yt_dlp, yt_dlp_installed, tmp_path, monkeypatch, language, expected
|
||||
):
|
||||
info = dict(VIDEO, language=language, automatic_captions={f"{language}-orig": []})
|
||||
monkeypatch.setattr(subprocess, "run", fake_yt_dlp(info, vtt=VTT))
|
||||
systems = recording_model(monkeypatch)
|
||||
run_main(monkeypatch, "-u", URL, "-o", tmp_path / "rede.korrigiert.txt")
|
||||
assert systems[0] == getattr(rk, expected)
|
||||
|
||||
|
||||
def test_main_url_unsupported_language(fake_yt_dlp, yt_dlp_installed, tmp_path, monkeypatch):
|
||||
info = dict(VIDEO, language="fr", automatic_captions={"fr-orig": []})
|
||||
monkeypatch.setattr(subprocess, "run", fake_yt_dlp(info, vtt=VTT))
|
||||
recording_model(monkeypatch)
|
||||
with pytest.raises(SystemExit, match="„fr“; unterstützt: de, en"):
|
||||
run_main(monkeypatch, "-u", URL, "-o", tmp_path / "rede.korrigiert.txt")
|
||||
|
||||
|
||||
def test_raw_text_path():
|
||||
assert rk.raw_text_path(Path("a/x.korrigiert.txt")) == Path("a/x.txt")
|
||||
assert rk.raw_text_path(Path("a/x.txt")) == Path("a/x.roh.txt")
|
||||
|
|
@ -449,7 +506,7 @@ def test_main_empty_input(tmp_path, monkeypatch):
|
|||
(["-i", "{sample}", "-g", "gibtsnicht.txt"], "Glossar nicht gefunden"),
|
||||
(["-i", "{sample}", "-g", str(GLOSSARY), "-g", "fehlt.txt"], "Glossar nicht gefunden: fehlt.txt"),
|
||||
(["-i", "{sample}", "-u", "https://x"], "not allowed with"),
|
||||
(["-i", "{sample}", "-l", "de"], "nur zusammen mit -u"),
|
||||
(["-i", "{sample}", "-l", "fr"], "wird nicht unterstützt"),
|
||||
])
|
||||
def test_cli_errors(sample_copy, monkeypatch, capsys, args, message):
|
||||
args = [a.format(sample=sample_copy) for a in args]
|
||||
|
|
|
|||
Loading…
Reference in a new issue