You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: CharacterSpaceConverter introduces whitespace holes and trailing whitespace #4043
CharacterSpaceConverter spaces out characters with " ".join(prompt) before removing punctuation with re.sub(...). This order of operations introduces whitespace artifacts:
Stripping punctuation leaves empty character "holes", producing 4 spaces between words (e.g., "Hello, world" -> "H e l l o w o r l d" instead of the standard 3-space inter-word spacing "H e l l o w o r l d").
Contractions or mid-word punctuation leave double spaces (e.g., "How's" -> "H o w s" instead of "H o w s").
Trailing punctuation leaves unwanted trailing whitespace (e.g., "hello!" -> "h e l l o ").
Additionally, the punctuation regex is recompiled on every invocation of convert_async rather than precompiled at module level.
Steps/Code to Reproduce
importasynciofrompyrit.converterimportCharacterSpaceConverterasyncdefmain():
converter=CharacterSpaceConverter()
res1=awaitconverter.convert_async(prompt="hello!")
print(repr(res1.output_text)) # prints 'h e l l o ' with trailing spaceres2=awaitconverter.convert_async(prompt="Hello, world! How's everything?")
print(repr(res2.output_text)) # prints 'H e l l o w o r l d H o w s e v e r y t h i n g 'asyncio.run(main())
Expected Results
Punctuation should be stripped prior to character spacing so spacing remains uniform without artificial gaps or trailing whitespace:
"hello!" -> 'h e l l o'
"Hello, world! How's everything?" -> 'H e l l o w o r l d H o w s e v e r y t h i n g'
Actual Results
'h e l l o '
'H e l l o w o r l d H o w s e v e r y t h i n g '
Activity
FIX: Strip punctuation before spacing in CharacterSpaceConverter (mic…