Skip to content

Conversation

@davaucl
Copy link

@davaucl davaucl commented Jan 17, 2026

Summary

  • Adds a new toggle in Transcript Modifications to convert spoken cardinal numbers to numeric digits
  • Examples: "twenty five" → "25", "one thousand three hundred thirty six" → "1336", "three point one four" → "3.14"
  • Conversion runs after word removals and before word remappings in the pipeline

Test plan

  • Open Settings → Transcript Modifications
  • Enable "Convert spoken numbers to digits" toggle
  • Test scratchpad preview with various number words
  • Record a transcription containing spoken numbers
  • Verify numbers appear as digits in output
  • Verify word boundaries preserved (e.g., "someone" unchanged)

Summary by CodeRabbit

  • New Features
    • New setting and UI toggle to convert spoken number words (e.g., "twenty-five", "one hundred", "three point five") into numeric digits in transcription output; supports hyphenated numbers, scales (thousand, million, etc.), and decimal "point" notation.
  • Tests
    • Added comprehensive tests covering basic numbers, compounds, decimals, mixed text, punctuation preservation, case-insensitivity, and edge cases.

✏️ Tip: You can customize this high-level summary in your review settings.

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.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

Adds a new NumberWordConverter, a public HexSettings flag convertNumberWordsToDigits, a UI toggle, integration into the transcription pipeline (applied before remappings), release metadata, and comprehensive unit tests validating conversions and edge cases.

Changes

Cohort / File(s) Summary
Release metadata
\.changeset/d3bf0f57.md
New changeset recording a minor bump and feature description.
Settings configuration
HexCore/Sources/HexCore/Settings/HexSettings.swift
Added public convertNumberWordsToDigits: Bool (default false) and updated public initializer; wired key into settings schema.
Conversion logic
HexCore/Sources/HexCore/Logic/NumberWordConverter.swift
New public NumberWordConverter with public static func apply(_:) -> String; tokenizes text, parses number-word sequences (ones, teens, tens, hyphenated, scales, optional "and"), handles decimals via "point", preserves punctuation/whitespace.
Feature integration & UI
Hex/Features/Transcription/TranscriptionFeature.swift, Hex/Features/Remappings/WordRemappingsView.swift
UI toggle bound to hexSettings.convertNumberWordsToDigits; transcription pipeline conditionally applies NumberWordConverter after removals and before remappings; logs when conversion changes output.
Tests
HexCore/Tests/HexCoreTests/NumberWordConverterTests.swift
New comprehensive test suite covering basic numbers, compounds, hyphenated/tens, scales, decimals, mixed text, punctuation, boundaries, case-insensitivity, and edge cases.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I nibble "twenty" and turn it bright,
Words to digits in a single bite,
A toggle twitch, a subtle trick,
Spoken numbers become quick and slick,
Hooray — concise digits hop into sight!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a new feature that converts spoken number words to digits in transcription output.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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)
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.

1 participant