Add option to convert spoken number words to digits#155
Add option to convert spoken number words to digits#155davaucl wants to merge 5 commits intokitlangton:mainfrom
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.
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)
- Backfill missing minor changeset for prior AI transforms (d53b16c) - Add minor changeset for spoken year conversion mode - Restore original number-word changeset summary for PR kitlangton#155 context
Summary
Test plan
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.