fix: „Zu prüfen“ übersah Streichungen von „er“/„um“ und Glossar-Allerweltswörter
- Füllwörter je Sprache: „er“ und „um“ sind nur im Englischen Füllwörter; im Deutschen wurde ihre Streichung bisher nie gemeldet. - Eine Änderung gilt nur noch als vom Glossar erklärt, wenn die neuen Wörter zusammenhängend in einem Eintrag stehen und dem alten Text ähneln. Bisher machte jedes Wort eines Eintrags („Sie“ aus „finden Sie“) Änderungen unsichtbar, auch eingefügte Vornamen. - aenderungen.py -l en-US findet die englische Wortliste. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1e3c813137
commit
45bf2da07b
1 changed files with 85 additions and 31 deletions
|
|
@ -124,8 +124,10 @@ def test_cli_missing_file(tmp_path, monkeypatch, capsys):
|
|||
WORDS = {"professor", "das", "dass", "ist", "haus", "unterschreiben", "bar"}
|
||||
|
||||
|
||||
def suspects(model_input, corrected, wordlist=WORDS, known=()):
|
||||
found = ae.review_candidates(ae.compare(model_input, corrected), wordlist, set(known))
|
||||
def suspects(model_input, corrected, wordlist=WORDS, glossary=(), fillers=ae.FILLERS["de"]):
|
||||
found = ae.review_candidates(
|
||||
ae.compare(model_input, corrected), wordlist, glossary, fillers
|
||||
)
|
||||
return [(s.reason, s.old, s.new) for s in found]
|
||||
|
||||
|
||||
|
|
@ -153,13 +155,37 @@ def test_review_candidates_ignores(model_input, corrected):
|
|||
assert suspects(model_input, corrected) == []
|
||||
|
||||
|
||||
def test_review_candidates_glossary_words_are_known():
|
||||
known = ae.glossary_words(["Egon Bahr"], [("Bars", "Bahrs")])
|
||||
assert known == {"egon", "bahr", "bahrs"}
|
||||
assert suspects("Bar sagte", "Bahr sagte", known=known) == []
|
||||
def test_review_candidates_glossary_spellings_are_not_reported():
|
||||
glossary = ae.glossary_entries(["Egon Bahr", ""], [("Bars", "Bahrs")])
|
||||
assert glossary == {("egon", "bahr"), ("bahrs",)}
|
||||
assert suspects("Bar sagte", "Bahr sagte", glossary=glossary) == []
|
||||
assert suspects("Bar sagte", "Bahr sagte") == [(ae.VALID_WORD, "Bar", "Bahr")]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model_input, corrected, expected", [
|
||||
# A common word of a longer entry explains nothing on its own
|
||||
("das sagt ihn nicht", "Das sagt Sie nicht.", [(ae.CHANGED_A_LOT, "ihn", "Sie")]),
|
||||
# Inserted words stay suspect even if they are in the glossary
|
||||
("er kam heute", "er ist kam heute", [(ae.INSERTED, "", "ist")]),
|
||||
("Dobrind sagte", "Alexander Dobrindt sagte",
|
||||
[(ae.CHANGED_A_LOT, "Dobrind", "Alexander Dobrindt")]),
|
||||
])
|
||||
def test_review_candidates_glossary_explains_only_spellings(model_input, corrected, expected):
|
||||
glossary = ae.glossary_entries(
|
||||
["Alexander Dobrindt"], [("befinden Sie", "finden Sie"), ("is", "ist")]
|
||||
)
|
||||
assert suspects(model_input, corrected, glossary=glossary) == expected
|
||||
|
||||
|
||||
def test_review_candidates_fillers_per_language():
|
||||
# "er" and "um" are real German words; in English they are fillers
|
||||
assert suspects("dann kam er um zu helfen", "Dann kam, zu helfen.") == [
|
||||
(ae.DELETED, "er um", "")
|
||||
]
|
||||
english = suspects("so er we um go", "So we go.", fillers=ae.FILLERS["en"])
|
||||
assert english == []
|
||||
|
||||
|
||||
def test_review_candidates_without_wordlist():
|
||||
# Similar replacements of real words go unnoticed, the rest still counts
|
||||
assert suspects("Der Professor kam", "Der Professorin kam", wordlist=None) == []
|
||||
|
|
|
|||
Loading…
Reference in a new issue