FIX: rejoin words with the configured word_split_separator - #2593
Open
Umerkhan Golandaz (UmerkhanGolandaz) wants to merge 1 commit into
Open
Conversation
WordLevelConverter.convert_async splits the prompt on word_split_separator but the default join_words always rejoined with a space, so a custom separator was silently replaced in the output. EmojiConverter and BinAsciiConverter both expose the parameter, so "alpha,beta" converted with separator "," came back space-delimited. Rejoin with the separator the words were split on. A None separator splits on arbitrary whitespace, which has no single representation to restore, so it keeps joining with a space. The default separator is " ", so output is unchanged for every caller that does not set a custom separator. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Umerkhan Golandaz (UmerkhanGolandaz)
force-pushed
the
fix/word-level-converter-preserves-separator
branch
from
September 7, 2026 19:21
dadf928 to
07bd921
Compare
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.
Description
Fixes #2592.
WordLevelConverter.convert_asyncsplits the prompt onword_split_separator(word_level_converter.py:116), but the defaultjoin_wordsalways rejoined with a space (:91). The split and the join disagreed, so a custom separator was silently replaced in the output:EmojiConverterandBinAsciiConverterboth exposeword_split_separatorin their own constructors, so this is reachable through the public API.Changes
join_wordsrejoins with the separator the words were split on.Noneseparator splits on arbitrary whitespace, which has no single representation to restore, so it continues to join with a space.,,|,-,::), the unchanged default, theNonecase, and a custom separator combined with partial word selection.Why this is safe
The change is a no-op for every caller that does not set a custom separator:
word_split_separator=" "— the default — already joined with" "word_split_separator=None— still joins with" "Only the custom-separator path changes, and it is currently broken. No existing test asserted the old behavior:
tests/unit/converter/test_emoji_converter.py:53setsword_split_separator="|"but asserts only the identifier params, not the output.Subclasses that override
join_words(BinaryConverter,NatoConverter,FirstLetterConverter,UnicodeReplacementConverter,BinAsciiConverter) keep their own joining behavior.BinAsciiConverterdelegates tosuper().join_wordsoutside its all-words encodings, so it picks up the fix on that path.Tests
pytest tests/unit/converter/— 1445 passed, 34 skipped, including the 5 new testsruff format --checkandruff checkclean on both changed files