Fix: Prevent capitalization of contractions in Tie/Gerrish commands#962
Merged
LexiconCode merged 1 commit intoMay 8, 2026
Merged
Conversation
Python's built-in .title() incorrectly capitalizes letters following an apostrophe. This commit adds a regex post-processor to capitalization levels 2 (Tie) and 3 (Gerrish) to lowercase common English contractions and possessives while preserving proper names like O'Reilly.
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.
Fix: Prevent
Tiecommand from capitalizing letters after apostrophesDescription
Currently, the
TieandGerrishformatting commands (capitalization levels 2 and 3 intext_format.py) rely on Python's built-instr.title(). Because.title()treats apostrophes as word boundaries, it incorrectly capitalizes the letter immediately following an apostrophe during dictation (e.g.,"don't"becomes"Don'T").This PR adds a regex post-processing step (
re.subutilizing a lookbehind) to catch and lowercase common English contractions and possessives ('s,'t,'m,'d,'re,'ve,'ll) after the.title()method is applied. It specifically preserves proper nouns with apostrophes (e.g., "O'Reilly").Related Issue
N/A
Motivation and Context
Dictating common contractions with the
Tiecommand currently results in grammatically incorrect casing, which requires manual keyboard correction. This fix drastically improves the out-of-the-box dictation accuracy for standard English speech while maintaining the integrity of capitalized proper names.How Has This Been Tested
Tested locally within the Caster environment by dictating various phrases with the
Tiecommand active."amir's setup"➔ Previously:"Amir'S Setup"| Now:"Amir's Setup""don't stop"➔ Previously:"Don'T Stop"| Now:"Don't Stop""we're here"➔ Previously:"We'Re Here"| Now:"We're Here""o'reilly"➔ Previously:"O'Reilly"| Now:"O'Reilly"(Verified proper nouns are preserved)Types of changes
Checklist
Maintainer/Reviewer Checklist