Skip to content

fix(ru): split sentence-final abbreviations before Cyrillic starts - #57

Merged
yisding merged 4 commits into
mainfrom
codex/fix-sentence-merging-caused-by-abbreviations
Jun 12, 2026
Merged

yisding merged 4 commits into
mainfrom
codex/fix-sentence-merging-caused-by-abbreviations

Conversation

@yisding

@yisding yisding commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A recent expansion of the Russian abbreviation list caused sentence-final abbreviations (e.g. др, ср, англ, рус, etc.) to unconditionally protect their trailing period and therefore merge sentences when the following sentence began with a Cyrillic uppercase token.
  • The intent is to keep inline gloss/locale tags (e.g. англ. Moscow) joined while restoring genuine sentence boundaries when the next token is a new Cyrillic sentence.

Description

  • Added import unicodedata and a SENTENCE_FINAL_ABBREVIATIONS set listing language tags and common abbreviations that may legitimately end a sentence in Russian inside sentencesplit/lang/russian.py.
  • Implemented a helper _starts_with_cyrillic_upper and changed replace_period_of_abbr to use a conditional regex replacement that restores a real period when the following non-space character is a Cyrillic uppercase start and otherwise protects the period with the non-boundary placeholder; this preserves the previous protection for Latin-uppercase glosses and lowercase continuations.
  • Added regression tests in tests/lang/test_russian.py covering both split-before-Cyrillic cases (e.g. Это литература и др. Она важна.) and preserved join cases (e.g. Он читал англ. Moscow.).

Testing

  • Ran uv run pytest tests/lang/test_russian.py --color yes and the Russian tests passed.
  • Ran the full suite with uv run pytest --cov=sentencesplit tests/ --color yes and all tests passed (1703 passed, 8 xfailed in the run recorded here).
  • Ran code quality commands uv run ruff check . and uv run ruff format --check . which succeeded, and performed a manual PoC using sentencesplit.Segmenter(language='ru') to verify the reported examples split correctly.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8af789d6e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sentencesplit/lang/russian.py Outdated
@yisding
yisding merged commit 5de4ee2 into main Jun 12, 2026
7 checks passed
@yisding
yisding deleted the codex/fix-sentence-merging-caused-by-abbreviations branch June 12, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant