Fix merge_punctuations for multi-char words with apostrophes#1423
Open
Br1an67 wants to merge 1 commit intoSYSTRAN:masterfrom
Open
Fix merge_punctuations for multi-char words with apostrophes#1423Br1an67 wants to merge 1 commit intoSYSTRAN:masterfrom
Br1an67 wants to merge 1 commit intoSYSTRAN:masterfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
merge_punctuationsfails to merge words that end with a prepend punctuation character but are multi-character (e.g., Frenchj',l'). This causes word timestamps to incorrectly split these words.Root Cause
The check
previous["word"].strip() in prependedtests whether the entire stripped word is a single character in the punctuation string. Multi-character words likej'fail this check.Fix
Tests
Added
test_merge_punctuations_french_apostropheandtest_merge_punctuations_single_char.Fixes #1252