Files
orca/src/shared/dictation-transcript.test.ts
T
Kelvin Amoaba 1bf2276bdd fix(dictation): match the pill's Chinese and Japanese phrases to the inserted text, and space Korean ones (#40455)
* fix(dictation): join Chinese and Japanese phrases without a space, and space Korean ones

The shared transcript fold joined every phrase with a space, so the pill and
phone replies showed Chinese and Japanese text with spaces the inserted text
doesn't have. It now joins with the same rule as insertion. That rule treated
Hangul like Chinese and Japanese, so Korean phrases were inserted with no space
between sentences; Korean spaces words, so Hangul now spaces like Latin text.

* fix(dictation): don't space after Chinese and Japanese full-width punctuation

* fix(dictation): join retried phrases with the same spacing rule

* fix(dictation): escape the spacing rule's non-ASCII marks for the orcad bundle

The shared fold now pulls the spacing rule into the orcad server bundle, which
must stay ASCII. A rich-draft test pinned Hangul joining without a space; it
now expects the Korean spacing.
2026-11-09 19:39:34 +00:00

45 lines
1.5 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { DictationTranscript } from './dictation-transcript'
function fold(events: { type: 'partial' | 'final'; text: string }[]) {
const transcript = new DictationTranscript()
events.forEach((event) => transcript.accept(event))
return transcript.snapshot()
}
describe('DictationTranscript', () => {
it('joins Chinese and Japanese phrases without a space, as they are inserted', () => {
expect(
fold([
{ type: 'final', text: '西班牙人开始了殖民时期。' },
{ type: 'final', text: '2023年他们来自欧洲' },
{ type: 'partial', text: '然后' }
])
).toMatchObject({
committed: '西班牙人开始了殖民时期。2023年他们来自欧洲',
text: '西班牙人开始了殖民时期。2023年他们来自欧洲然后'
})
expect(
fold([
{ type: 'final', text: '今日は晴れです。' },
{ type: 'final', text: '散歩に行きます。' }
]).committed
).toBe('今日は晴れです。散歩に行きます。')
})
it('spaces Korean and Latin phrases', () => {
expect(
fold([
{ type: 'final', text: '안녕하세요.' },
{ type: 'final', text: '감사합니다.' }
]).committed
).toBe('안녕하세요. 감사합니다.')
expect(
fold([
{ type: 'final', text: 'Open the file.' },
{ type: 'partial', text: 'then save' }
]).text
).toBe('Open the file. then save')
})
})