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: InsertPunctuationConverter inserts punctuation inside words with accents or Indic vowel signs #4474
In its default between-words mode, InsertPunctuationConverter should only put punctuation before or after a word. But it splits words with \w+, which stops at combining marks (accents written as a separate code point, Indic vowel signs and viramas). Each mark becomes its own "non-word" token, so a word like नमस्ते is treated as several words and punctuation lands inside it, detaching the vowel sign from its letter. The word count used for word_swap_ratio is also wrong for these words.
This is the same class of bug fixed in SATAMaskingConverter by #4390.
# Words list contains single spaces, single word without punctuations, single punctuations
words=re.findall(r"\w+|[^\w\s]|\s", prompt)
re.findall(r"\w+|[^\w\s]|\s", prompt): combining marks are not \w, so they fall into [^\w\s] as separate tokens. Matching them as part of the preceding word (regex.findall(r"\w[\w\p{M}]*|[^\w\s]|\s", prompt), regex is already a dependency) fixes it.
Activity