uttrflow / uttrflow/uttrflow-swift
Self-correction deletes a Hinglish clause before "sorry" or "actually", because Hindi pronouns are not weak anchors: "main late hoon sorry main abhi aata hoon" becomes "Main abhi aata hoon."
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## What happens
`SelfCorrectionPass` treats "sorry" and "actually" as correction triggers (`Sources/UttrflowCore/Cleaning/Restatement.swift:4-8`). It then looks back for the word that follows the trigger. If it finds that word, it deletes from there up to the trigger (`discardedStart`, `:40-67`).
A fresh clause usually starts with a pronoun, so pronouns can't anchor a deletion. But `weakAnchors` (`:19-22`) lists English pronouns only: "i", "i'm", "we", "you", "he", "she", "they", "it", "that", "this", … In Hindi or Hinglish, the repeated pronoun (main, hum, wo, ye, मैं, वो) anchors, and a whole clause is deleted.
```
$ uttrflow-dev clean -e rules "main late hoon sorry main abhi aata hoon"
clean Main abhi aata hoon.
$ uttrflow-dev clean -e rules "मैं late हूँ sorry मैं अभी आता हूँ"
clean मैं अभी आता हूँ.
$ uttrflow-dev clean -e rules "he is not coming today actually he is coming tomorrow"
clean He is not coming today actually he is coming tomorrow.
```
The English sentence is protected by "he". Its Hinglish equivalent is not.
`FunctionWords.all` (`Sources/UttrflowCore/Cleaning/FunctionWords.swift:12`) is English as well, so `holdsContent` counts every Hindi word as content. That is why a clause made only of a pronoun and a verb still qualifies.
## Why it matters
"I'm late, sorry, I'm coming now" loses the apology and the reason. The meaning changes, and the reader gets a curt message the speaker didn't send.
The rules tidy most Hindi and Hinglish dictation (#445), so this path runs for exactly these users. A romanised Hinglish sentence is all ASCII, so the rules are also what an unavailable or declining model falls back to.
## Acceptance criteria
- `weakAnchors` holds the common Hindi pronouns and subject words in both scripts. At least: main, mai, hum, tum, aap, wo, woh, ye, yeh, mera, meri, मैं, हम, तुम, आप, वो, वह, ये, यह.
- `Tests/UttrflowAITests/Passes/SelfCorrectionPassTests.swift` pins the two Hinglish sentences above as unchanged. The English cases already there still pass. (Hinglish restatements that should be corrected are a separate question, in #703.)
- The Hinglish cases join the clean-up corpus's multilingual section (`Sources/UttrflowEval/EvaluationCorpus.swift:558`) with `mustKeep: ["late"]`.
Contributor guide
Research direction
Start with SelfCorrectionPass in Sources/UttrflowCore/Cleaning/Restatement.swift, especially weakAnchors and the discardedStart logic. Run the existing SelfCorrectionPassTests.swift, then add the two Hinglish examples unchanged and place them in the multilingual section of Sources/UttrflowEval/EvaluationCorpus.swift with mustKeep: ["late"].
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- desktop, internationalization, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100