Skip to content

Fix: Prevent capitalization of contractions in Tie/Gerrish commands#962

Merged
LexiconCode merged 1 commit into
dictation-toolbox:masterfrom
amirf147:bugfix/title-case-logic
May 8, 2026
Merged

Fix: Prevent capitalization of contractions in Tie/Gerrish commands#962
LexiconCode merged 1 commit into
dictation-toolbox:masterfrom
amirf147:bugfix/title-case-logic

Conversation

@amirf147
Copy link
Copy Markdown
Contributor

@amirf147 amirf147 commented May 8, 2026

Fix: Prevent Tie command from capitalizing letters after apostrophes

Description

Currently, the Tie and Gerrish formatting commands (capitalization levels 2 and 3 in text_format.py) rely on Python's built-in str.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.sub utilizing 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 Tie command 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 Tie command 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

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue or bug)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Renamed existing command phrases (we discourage this without a strong rationale).

Checklist

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • I have checked that my code does not duplicate functionality elsewhere in Caster.
  • I have checked for and utilized existing command phrases from within Caster (delete if not applicable).
  • My code implements all the features I wish to merge in this pull request.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests pass.

Maintainer/Reviewer Checklist

  • Basic functionality has been tested and works as claimed.
  • New documentation is clear and complete.
  • Code is clear and readable.

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.
@LexiconCode LexiconCode added Caster Core Spec Issues for Caster Specs that are not part of the application or language specific grammar/ccr BugFix Resolves unexpected behavior from existing features. labels May 8, 2026
@LexiconCode LexiconCode merged commit a6f7849 into dictation-toolbox:master May 8, 2026
3 checks passed
@amirf147 amirf147 deleted the bugfix/title-case-logic branch May 8, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BugFix Resolves unexpected behavior from existing features. Caster Core Spec Issues for Caster Specs that are not part of the application or language specific grammar/ccr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants