arpabet-and-ipa-convertor-ts
Version:
Typescript code to convert between Arpabet and IPA phonetic transcriptions
55 lines (54 loc) • 2.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var to_phonetic_alphabets_1 = require("./to-phonetic-alphabets");
describe('ARPAbet2PhoneticAlphabet', function () {
it('Monosyllable', function () {
// 单音节
var result = to_phonetic_alphabets_1.toAmericanPhoneticAlphabet('F AW1 N D');
expect(result).toEqual('faʊnd');
});
it('Double syllable', function () {
// ri'trai 双音节
var result = to_phonetic_alphabets_1.toAmericanPhoneticAlphabet('R IY0 T R AY1');
expect(result).toEqual('riˈtraɪ');
});
it('Trisyllable', function () {
// ˈɛniˌwʌn, -wən 三音节
var result = to_phonetic_alphabets_1.toAmericanPhoneticAlphabet('EH1 N IY0 W AH2 N');
expect(result).toEqual('ˈɛniˌwʌn');
});
it('Monosyllable', function () {
// kʊd 单音节
var result = to_phonetic_alphabets_1.toAmericanPhoneticAlphabet('K UH1 D');
expect(result).toEqual('kʊd');
});
it('Double syllable', function () {
// 双音节
var result = to_phonetic_alphabets_1.toAmericanPhoneticAlphabet("W IY1 L K IY0 N S N");
expect(result).toEqual('ˈwilkinsn');
});
it('Edge test: wrong accent mark', function () {
// 边缘测试:重音标识不对
expect(function () {
to_phonetic_alphabets_1.toAmericanPhoneticAlphabet("W IY1 L K IY4 N S N");
}).toThrow('The accent mark of IY is wrong, it is marked as 4'); // IY 的重音标识不对,标记成了 4
});
it('Edge test: ARPAbet is wrong', function () {
// 边缘测试:ARPAbet不对
expect(function () {
to_phonetic_alphabets_1.toAmericanPhoneticAlphabet("W IY1 L K IG N S N");
}).toThrow('IG does not match the appropriate phonetic transcription'); // IG 匹配不到合适的音标
});
it('Edge test: wrong accent mark position', function () {
// 边缘测试:重音标识位置不对
expect(function () {
to_phonetic_alphabets_1.toAmericanPhoneticAlphabet("W IY1 L K IY N1 S N");
}).toThrow('N1 The accent mark is in the wrong position, the current N is not a vowel'); // N1 重音标识位置不对,当前 N 不是元音
});
it('Edge test: ARPAbet marked with accent is wrong', function () {
// 边缘测试:标记重音的ARPAbet不对
expect(function () {
to_phonetic_alphabets_1.toAmericanPhoneticAlphabet("W IY1 L K IY X1 S N");
}).toThrow('X does not match the appropriate phonetic transcription'); // X 匹配不到合适的音标
});
});