zhujun24/chinese-to-pinyin

errors occurred when dealing with hanzi "的"

Closed this issue · 5 comments

Hi @zhujun24,
Thanks for the great plugin.
I noticed that when a sentence coontains "的" with the setting numberTone:true
An error of "TypeError: Cannot read property '1' of undefined" will occur.
The following is an example.
var pinyin = require("chinese-to-pinyin");
pinyin('今天的天气真好', {numberTone: true});
and the error disappeared after "的" is removed.
Is it a bug?

BTW, is it possible to fetch the numberTone only?
I need to convert pinyin to zhuyin for further processing.
or would you please make an option for converting to either pinyin or zhuyin.
Regards,

shilik

I have fixed in v0.1.7, and also add numberToneOnly option to return numberTone only, Try it! Wish for your feedback.

Thanks for the quick reply.
As for the numberToneOnly option, it returns something other than "numbers".
Anything wrong with this option?

Here are results for your reference.

JS: 'no tone:' 'jin tian tian qi zhen hao'
JS: 'number tone only:' 'jīn tiān tiān qì zhēn hǎo'
JS: 'with tone:' 'jin1 tian1 tian1 qi4 zhen1 hao3'

I have split numberTone and numberToneOnly option, please try v0.1.8.

wow!,great.
That is exactly what I need.
Thank you very much!

Regards

You are Welcome!