Skip to content

Fix merge_punctuations for multi-char words with apostrophes#1423

Open
Br1an67 wants to merge 1 commit intoSYSTRAN:masterfrom
Br1an67:fix/apostrophe-word-split
Open

Fix merge_punctuations for multi-char words with apostrophes#1423
Br1an67 wants to merge 1 commit intoSYSTRAN:masterfrom
Br1an67:fix/apostrophe-word-split

Conversation

@Br1an67
Copy link

@Br1an67 Br1an67 commented Mar 1, 2026

Problem

merge_punctuations fails to merge words that end with a prepend punctuation character but are multi-character (e.g., French j', l'). This causes word timestamps to incorrectly split these words.

Root Cause

The check previous["word"].strip() in prepended tests whether the entire stripped word is a single character in the punctuation string. Multi-character words like j' fail this check.

Fix

  • Prepended: check if word ends with any punctuation char
  • Appended: check if word starts with any punctuation char

Tests

Added test_merge_punctuations_french_apostrophe and test_merge_punctuations_single_char.

Fixes #1252

The previous logic checked if the entire stripped word was a single
character present in the punctuation string. Words like "j'" or "l'"
(common in French) failed this check because they are multi-character.

Changed to check if the word ends with (for prepended) or starts with
(for appended) any punctuation character, so that words containing
punctuation are properly merged with adjacent words.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX INCLUDED] BatchedInferencePipeline.transcribe does not seem to use append_punctuations and preprend_punctuations properly

1 participant