uttrflow / uttrflow/uttrflow-swift
A number self-correction followed by its unit keeps both halves: "twelve boxes I mean fifteen boxes" is inserted unchanged
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## What happens
`Restatement.discardedStart` handles a correction between numbers only when the word right before the trigger is itself a number (`Sources/UttrflowCore/Cleaning/Restatement.swift:45`). When the speaker repeats the unit, which is the natural way to say it, the word before the trigger is the unit, the number branch is skipped, and the shape branch looks for the first word after the trigger ("fifteen"/"50") earlier in the sentence, does not find it, and gives up. Both halves and the trigger are inserted.
Rules only, `uttrflow-dev clean --engine rules` on main:
| Input | Output |
|---|---|
| `the total is forty no wait fifty` | `The total is 50.` (works) |
| `the total is forty dollars no wait fifty dollars` | `The total is 40 dollars no wait 50 dollars.` |
| `it costs forty dollars sorry fifty dollars` | `It costs 40 dollars sorry 50 dollars.` |
| `we need twelve boxes i mean fifteen boxes` | `We need 12 boxes I mean 15 boxes.` |
| `invite ten people no wait twelve people` | `Invite 10 people no wait 12 people.` |
The corpus has `actually-between-numbers` ("coffee at two actually three") but no case with a unit.
## Why it matters
Quantities with units are the everyday form of a numeric correction (money, counts, durations). The trigger words and the wrong number stay in the message.
## How to reproduce
```
swift build -c release --product uttrflow-dev
.build/release/uttrflow-dev clean --engine rules 'we need twelve boxes i mean fifteen boxes'
```
## Acceptance criteria
- A number followed by the same unit word on both sides of a trigger is treated as the number branch: the four failing rows above lose the first quantity and the trigger.
- It does not fire when the units differ ("ten apples actually twelve pears") or across a sentence end (#199).
- Tests in `Tests/UttrflowCoreTests/RestatementTests.swift`; a corpus case added and listed in `RulesCorpusTests.rulesMustPass`.
Contributor guide
Research direction
Start in Sources/UttrflowCore/Cleaning/Restatement.swift around discardedStart and reproduce the issue with the rules-engine command shown. Add coverage in Tests/UttrflowCoreTests/RestatementTests.swift and add a corpus case to RulesCorpusTests.rulesMustPass. Done means matching units are discarded with the trigger, differing units and sentence boundaries are preserved, and all listed rows pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100