-
-
Notifications
You must be signed in to change notification settings - Fork 67
Add option to convert spoken number words to digits #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Adds a new toggle in Transcript Modifications that converts spoken cardinal numbers to numeric digits during transcription post-processing. Examples: - "twenty five" → "25" - "one thousand three hundred thirty six" → "1336" - "three point one four" → "3.14" The conversion runs after word removals and before word remappings, allowing users to further customize the output.
📝 WalkthroughWalkthroughAdds a new NumberWordConverter, a public HexSettings flag Changes
Sequence DiagramsequenceDiagram
participant User
participant UI as WordRemappingsView
participant Settings as HexSettings
participant Transcription as TranscriptionFeature
participant Converter as NumberWordConverter
User->>UI: Toggle "Convert spoken numbers to digits"
UI->>Settings: set convertNumberWordsToDigits = true
User->>Transcription: Start transcription
Transcription->>Settings: read convertNumberWordsToDigits
alt enabled
Transcription->>Converter: apply(interimOutput)
Converter->>Converter: tokenize & parse number-word sequences
Converter-->>Transcription: return converted text
Transcription->>Transcription: apply word remappings
else disabled
Transcription->>Transcription: apply word remappings
end
Transcription-->>User: deliver final transcription
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @.changeset/d3bf0f57.md:
- Around line 1-5: Update the changeset summary text to include the PR number
for this change; specifically edit the description line "Add option to convert
spoken number words to digits" to append the PR reference in parentheses (e.g.,
"Add option to convert spoken number words to digits (`#PR_NUMBER`)"), keeping the
existing release header for "hex-app": minor intact so the changeset follows
repo guidance.
In `@HexCore/Sources/HexCore/Logic/NumberWordConverter.swift`:
- Around line 148-190: The decimal parsing stops at whitespace after "point" and
rejects cases where total == 0, so update logic in NumberWordConverter
(variables/functions: inDecimal, hasDecimal, lastWasNumber, decimalString,
tokensConsumed, i, ones, connectors, isNumberWord) to: when encountering
whitespace immediately after "point" while inDecimal is true or lastWasNumber is
true, peek past intervening whitespace and allow decimal digit tokens to be
consumed (advance i and tokensConsumed over whitespace then parse digits into
decimalString); and ensure the final acceptance check does not reject a valid
decimal just because total == 0 (allow conversion when hasDecimal is true even
if total equals 0) so inputs like "three point one four" and "zero point five"
produce correct decimal results.
- When in decimal mode, peek past whitespace to find digit tokens - Accept valid decimals even when integer part is zero (e.g., 'zero point five' → '0.5') - Fixes 'three point one four' → '3.14' (was stopping at whitespace after 'point') - Fixes 'zero point five' → '0.5' (was rejecting due to total == 0)
Summary
Test plan
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.