Skip to content

Add repeating character preprocessor - #2444

Open
ShreyasB1 wants to merge 3 commits into
gunthercox:masterfrom
ShreyasB1:add-repeating-character-preprocessor
Open

Add repeating character preprocessor#2444
ShreyasB1 wants to merge 3 commits into
gunthercox:masterfrom
ShreyasB1:add-repeating-character-preprocessor

Conversation

@ShreyasB1

Copy link
Copy Markdown

Add a preprocessor that reduces runs of three or more repeated letters
down to two (e.g. "sooooo" -> "soo"). Elongated words are common in
conversational input, and normalizing them maps spelling variations to a
consistent form so the chat bot can match input against trained
statements more reliably.

Repeated digits and punctuation are left unchanged, and naturally
occurring double letters (such as the "oo" in "cool") are preserved.

Includes unit tests and documentation for the new preprocessor.

@jocelyn1981

jocelyn1981 commented Jun 7, 2026 via email

Copy link
Copy Markdown

@ShreyasB1

Copy link
Copy Markdown
Author

Hi! I was wondering the timeline for this feature being approved.

preserved, and repeated digits or punctuation are left unchanged.
"""
statement.text = _REPEATING_CHARACTER_PATTERN.sub(
lambda match: match.group(1) * 2, statement.text

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking a look at some related sample data, it appears that this regex would group a statement such as "I am sooooo happy" with "I am soo happy" (x2 characters), which still doesn't quite reach the intended token of "so".

I'm not certain this works as intended in some of the cases the pull request was expecting. Perhaps there is another approach that might work better? (If not, a project-specific preprocessor is always an alternative option to including one in the main codebase.

@syedkosaainhaider-maker

Copy link
Copy Markdown

ok

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.

4 participants