Files
homeclaw/tests/speech-dates.test.ts
T
kimandClaude Sonnet 5.5 8cab4fd45b 낭독: 연도 없는 슬래시 날짜(10/30, 11/2~11/8)를 "M월 D일"로 — "십 삼십 토요일" 수정
답변에 "내일(10/30)", "11/2 월요일", "11/3~4"처럼 연도 없는 슬래시 날짜가 자주 나오는데, sanitizeForSpeech는 연도가 붙은 날짜만 월·일로 바꿔서 숫자만 한글로 풀려 월·일이 통째로 빠졌다(엔진 문제가 아니라 규칙 누락).
- speech-dates.js(신규): 월≤12·일≤31이고 (앞수>뒷수 | 뒷수>12 | 뒤에 요일 | 앞에 오늘·내일·기준·발표 등 말머리)일 때만 날짜로 본다. 분수(1/2·3/4)·24/7·단위(m/s)는 보존. 점 표기(10.30)는 바로 뒤에 요일이 있을 때만. 범위(11/2~11/8, 11/3~4, 10/30(토)~10/31(일))는 "A에서 B", "일는→일은" 조사 보정.
- voice-call.js sanitizeForSpeech가 단위 낭독보다 먼저 호출하고(통화·🔊 읽기 버튼 공통), index.html에서 로드.
- tests/speech-dates.test.ts 8개 추가(speech-units·speech-tables 포함 22개 통과).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-31 00:05:06 +09:00

51 lines
2.4 KiB
TypeScript

/**
* speech-dates — TTS가 연도 없는 슬래시 날짜를 "십 삼십"으로 읽어 월·일이 빠지던 문제(2026-10-30).
* 표본: 같은 날 어시스턴트 답변의 "내일(10/30)", "11/2 월요일", "11/2~11/8", "11/3~4".
*/
import { test, describe } from 'node:test';
import assert from 'node:assert/strict';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { spellDatesForSpeech: f } = require('../web-ui/js/voice/speech-dates.js');
describe('spellDatesForSpeech', () => {
test('슬래시 날짜는 월·일로', () => {
assert.equal(f('내일(10/30)은 강수'), '내일(10월 30일)은 강수');
assert.equal(f('기상청 10/28 23시 발표 기준'), '기상청 10월 28일 23시 발표 기준');
assert.equal(f('11/5 구름많음'), '11월 5일 구름많음');
});
test('요일이 붙으면 모호한 꼴도 날짜', () => {
assert.equal(f('11/2 월요일은 비'), '11월 2일 월요일은 비');
assert.equal(f('9/11(월)'), '9월 11일(월)');
assert.equal(f('3/4 토요일'), '3월 4일 토요일');
});
test('범위: 11/2~11/8, 11/3~4', () => {
assert.equal(f('다음 주(11/2~11/8) 예보'), '다음 주(11월 2일에서 11월 8일) 예보');
assert.equal(f('11/3~4는 맑고'), '11월 3일에서 4일은 맑고');
assert.equal(f('주말 10/30(토)~10/31(일)'), '주말 10월 30일(토)에서 10월 31일(일)');
});
test('날짜 말머리가 있으면 모호한 꼴도 날짜', () => {
assert.equal(f('내일 9/11 도착'), '내일 9월 11일 도착');
});
test('점 표기는 요일이 붙을 때만', () => {
assert.equal(f('10.30(토)'), '10월 30일(토)');
assert.equal(f('10.30 토요일'), '10월 30일 토요일');
assert.equal(f('기온 10.30도'), '기온 10.30도');
assert.equal(f('가격 3.5배'), '가격 3.5배');
});
test('분수·비율·단위는 건드리지 않는다', () => {
assert.equal(f('1/2컵'), '1/2컵');
assert.equal(f('3/4 정도'), '3/4 정도');
assert.equal(f('24/7 운영'), '24/7 운영');
assert.equal(f('풍속 2.6 m/s'), '풍속 2.6 m/s');
assert.equal(f('성공률 9/10'), '성공률 9/10');
});
test('연도가 붙은 날짜는 그대로 둔다(뒤 규칙이 처리)', () => {
assert.equal(f('2026/10/30'), '2026/10/30');
assert.equal(f('2026-10-30'), '2026-10-30');
});
test('빈 입력', () => {
assert.equal(f(''), '');
assert.equal(f(null), '');
});
});