49 lines
2.3 KiB
TypeScript
49 lines
2.3 KiB
TypeScript
/**
|
|
* speech-units — TTS가 영문 단위 기호를 글자 이름으로 읽는 문제(2026-10-17 "그램을 지라고 읽는다").
|
|
*/
|
|
import { test, describe } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
const { spellUnitsForSpeech: f } = require('../web-ui/js/voice/speech-units.js');
|
|
|
|
describe('spellUnitsForSpeech', () => {
|
|
test('숫자에 붙은 단위를 한글로', () => {
|
|
assert.equal(f('설탕 50g 넣고'), '설탕 50그램 넣고');
|
|
assert.equal(f('72.5kg'), '72.5킬로그램');
|
|
assert.equal(f('15 cm'), '15센티미터');
|
|
assert.equal(f('256GB'), '256기가바이트');
|
|
assert.equal(f('3.4GHz'), '3.4기가헤르츠');
|
|
assert.equal(f('1013hPa'), '1013헥토파스칼');
|
|
assert.equal(f('35㎍/㎥'), '35마이크로그램 퍼 세제곱미터');
|
|
});
|
|
test('복합 단위가 단일 단위보다 먼저', () => {
|
|
assert.equal(f('3.2m/s'), '3.2미터 매 초');
|
|
assert.equal(f('40km/h'), '40킬로미터 매 시');
|
|
assert.equal(f('2.5mm'), '2.5밀리미터');
|
|
});
|
|
test('조사가 붙어도 변환, 영단어·숫자 없는 글자는 그대로', () => {
|
|
assert.equal(f('100m를 달렸다'), '100미터를 달렸다');
|
|
assert.equal(f('5mins left'), '5mins left');
|
|
assert.equal(f('The A team and g'), 'The A team and g');
|
|
});
|
|
test('섭씨·달러', () => {
|
|
assert.equal(f('21.5℃'), '섭씨 21.5도');
|
|
assert.equal(f('$100'), '100달러');
|
|
});
|
|
|
|
test('실사용 로그에서 빠졌던 단위(cm³·fps·t/s·TFLOPS·Nm·MP·mg/dL)', () => {
|
|
assert.equal(f('43cm³'), '43세제곱센티미터');
|
|
assert.equal(f('60fps'), '60프레임 매 초');
|
|
assert.equal(f('18 t/s'), '18토큰 매 초');
|
|
assert.equal(f('13TFLOPS'), '13테라플롭스');
|
|
assert.equal(f('17Nm'), '17뉴턴미터');
|
|
assert.equal(f('12MP'), '12메가픽셀');
|
|
assert.equal(f('110mg/dL'), '110밀리그램 퍼 데시리터');
|
|
assert.equal(f('5.5mmol/L'), '5.5밀리몰 퍼 리터');
|
|
assert.equal(f('4000mAh'), '4000밀리암페어시');
|
|
});
|
|
test('충돌하는 표기는 건드리지 않는다', () => {
|
|
for (const s of ['1990s 노래', '5W1H 원칙', '3D 프린터', '4K 모니터', '5G 통신', '37.5N', '2000년대']) assert.equal(f(s), s);
|
|
});
|
|
});
|