@@ -99,8 +99,9 @@ const getPinyinWithoutTone: GetPinyinWithoutTone = (pinyin) => {
99
99
. replace ( / ( ī | í | ǐ | ì ) / g, "i" )
100
100
. replace ( / ( ū | ú | ǔ | ù ) / g, "u" )
101
101
. replace ( / ( ǖ | ǘ | ǚ | ǜ ) / g, "ü" )
102
- . replace ( / ( ń | ň | ǹ ) / g, "n" )
103
- . replace ( / ḿ | m ̀ / g, "m" ) ;
102
+ . replace ( / ( n ̄ | ń | ň | ǹ ) / g, "n" )
103
+ . replace ( / ( m ̄ | ḿ | m ̌ | m ̀ ) / g, "m" )
104
+ . replace ( / ( ê ̄ | ế | ê ̌ | ề ) / g, "ê" ) ;
104
105
} ;
105
106
106
107
/**
@@ -224,11 +225,12 @@ const getFinalParts: GetFinalParts = (pinyin) => {
224
225
*/
225
226
type GetNumOfTone = ( pinyin : string ) => string ;
226
227
const getNumOfTone : GetNumOfTone = ( pinyin ) => {
227
- const reg_tone1 = / ( ā | ō | ē | ī | ū | ǖ ) / ;
228
- const reg_tone2 = / ( á | ó | é | í | ú | ǘ | ń | ḿ ) / ;
229
- const reg_tone3 = / ( ǎ | ǒ | ě | ǐ | ǔ | ǚ | ň ) / ;
230
- const reg_tone4 = / ( à | ò | è | ì | ù | ǜ | ǹ | m ̀ ) / ;
231
- const reg_tone0 = / ( a | o | e | i | u | ü | n ) / ;
228
+ const reg_tone1 = / ( ā | ō | ē | ī | ū | ǖ | n ̄ | m ̄ | ê ̄ ) / ;
229
+ const reg_tone2 = / ( á | ó | é | í | ú | ǘ | ń | ḿ | ế ) / ;
230
+ const reg_tone3 = / ( ǎ | ǒ | ě | ǐ | ǔ | ǚ | ň | m ̌ | ê ̌ ) / ;
231
+ const reg_tone4 = / ( à | ò | è | ì | ù | ǜ | ǹ | m ̀ | ề ) / ;
232
+ const reg_tone0 = / ( a | o | e | i | u | ü | ê ) / ;
233
+ const special_tone = / ( n | m ) $ / ;
232
234
const tone_num_arr : string [ ] = [ ] ;
233
235
const pinyin_arr = pinyin . split ( " " ) ;
234
236
pinyin_arr . forEach ( ( _pinyin ) => {
@@ -242,6 +244,8 @@ const getNumOfTone: GetNumOfTone = (pinyin) => {
242
244
tone_num_arr . push ( "4" ) ;
243
245
} else if ( reg_tone0 . test ( _pinyin ) ) {
244
246
tone_num_arr . push ( "0" ) ;
247
+ } else if ( special_tone . test ( _pinyin ) ) {
248
+ tone_num_arr . push ( "0" ) ;
245
249
} else {
246
250
tone_num_arr . push ( "" ) ;
247
251
}
0 commit comments