Skip to content

Commit

Permalink
feat: Define valid sentence endings more strictly
Browse files Browse the repository at this point in the history
  • Loading branch information
gremid committed Dec 19, 2024
1 parent 1b3e16b commit 04e128a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gdex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ def _de_is_misparsed(sent: Span) -> bool:
return True

last_token = tokens[-1]
if last_token.pos_ != "PUNCT":
if last_token.text not in {".", "?", "!"}:
return True

if (sum((1 for t in tokens if t.tag_ == "$(")) % 2) != 0:
return True

return False
Expand Down
9 changes: 9 additions & 0 deletions tests/test_gdex.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ def test_misparsed():
assert_knockout("Ein Satz ohne Satzzeichen")
assert_knockout("ein Satz, der mit Kleinbuchstaben beginnt.")
assert_knockout(": Ein Satz mit Interpunktion am Anfang.")
assert_knockout("Ein Satz, der nach einem Komma geteilt wurde,")
assert_knockout("Der nächste Satz gehört inhaltlich eng zu diesem:")
assert_knockout(
(
'"Durch das Kriterium werden auch alle Sätze, die mit '
'Anführungszeichen beginnen und/oder enden, ausgeschlossen."'
)
)
assert_knockout('Die Kulisse habe "eine malerische Qualität."')


def test_finite_verb_and_subject():
Expand Down

0 comments on commit 04e128a

Please sign in to comment.