Follow-up to #2414. Two hand checks found cases where SpokenNumbers was wrong:
Ryan's 320 sentences written to break it, and a 340-clip stress test in five
voices.
What changed (SpokenNumbers.swift):
- A: "a hundred"/"a thousand" joins the number that follows it ("a hundred and
fifty" 150, "a hundred and ten percent" 110%). On its own it stays as said
("a hundred percent", "a hundred dollars"). Before: "a hundred and 50".
- B: a decimal takes a two-word fraction ("one point twenty one" 1.21).
Before: "One point 21".
- New guard: a number word right after "hundred and", "thousand and" or
"<number> point" counts as the rest of a number not taken whole and stays
as said. No output now joins a digit to a word of the same number.
- C: a number the engine capitalised as a name stays as said when another
capitalised word follows ("Twenty One Pilots", "Eleven Labs", "Fifty Shades",
"Ten Thousand Villages"). This applies mid-sentence, or anywhere when a later
word of the number is capitalised. "Area fifty one", "Forever Twenty One" and
"Twenty people came" still convert.
- D: digits(in:language:protectedTerms:) leaves custom vocabulary and learned
words alone, matched word by word without case. CleanupTagger.cleanIfEnabled
passes the protectedTerms it already receives.
- E: a range ending in "percent" counts as a range with a unit (10 to 15%).
- F: with the second number of "in", "out of" or "to" (a scale or decimal) in
digits, the first follows ("1 in 10", "8 out of 10", "0 to 100"), and so do
the inches after a height ("5 foot 6"; Apple's "6 foot two" becomes
"6 foot 2"). Arithmetic stays as said, whole ("ten minus five is five").
"two to three hundred" and "one or two hundred" stay as said rather than
becoming "2 to 300".
- G: a lower-case "oh" mid-sentence leads a run of three or more digits
("oh four seven two" 0472). "Oh one more thing" stays, and so does a run
right after such an "Oh".
Verified:
- xcodebuild test on the Mac Studio (iPhone 17 Pro simulator, iOS 27.2) on
this tree over dev 06ac30af: 899 tests, 0 failures, 4 skipped. Ryan's
sentences whose behaviour changed are cases in TranscriptCleanupTests: 22
conversions, 20 that stay, and 4 protected terms plus the cleanIfEnabled
path. Every case asserts that no number is left half converted.
- Harness over 2,143 texts (Ryan's 326 sentences, the 80 sentences from both
engines, the 755-text corpus, the stress test's 690 raw texts): 0 numbers
left half converted (the merged rule left 6). The corpus and the stress test
are unchanged from #2414 except where listed in the PR.
- python3 scripts/code-shape.py passes.