mozillazg / go-pinyin

汉字转拼音
https://godoc.org/github.com/mozillazg/go-pinyin
MIT License
1.6k stars 194 forks source link

w开头的字输出有误 #18

Open wdscxsj opened 7 years ago

wdscxsj commented 7 years ago
$ pinyin -s Initials 五个
 g
$ pinyin -s FinalsTone 文武
uén uǔ
mozillazg commented 7 years ago

@wdscxsj 第一个没有问题,因为 w 既不是声母也不是韵母,第二个 没错, 有点问题。

详见: 汉语拼音方案 【韵母表】备注 (4)

wdscxsj commented 7 years ago

我在音韵方面所知寥寥,以下粗浅想法仅供参考。

拼音单韵母i、u、ü之前如果没有声母,就应另加零声母y、w、y。这在1958年林汉达先生奠基性的《汉语拼音自修课本》中,称为“头母”(1985年文字改革出版社重版,第20页)。

现代汉语语法体系从西语语法体系借鉴良多,1955年我国自创注音字母失败后,也直接采用拉丁字母作为汉语拼音的基础。这种“捡现成”的好处是立等可用,一个缺陷就是难免削足适履,未能圆融自洽。我们用主谓宾名动行之类的洋词套到汉语头上时,刚开始还好,越深入越会觉得怪模怪样。

零声母是什么?一共有几个零声母?中山大学的poem开门见山地说:“「零聲母」是一個很難定義準確的概念,建議不必使用。「零聲母」的概念,估計是在翻譯引進音系學時,參照模仿zero phoneme的概念提出的。本意似乎是想在對於缺少聲母音位時用「零聲母」來填充。”中文维基百科也把“零声母”列为“有争议的”(https://zh.wikipedia.org/wiki/声母)。

我比较赞同上面的观点,倾向于把“零声母”看作未能合理本土化的“边角料”。“零”想表达的应该不是nothing,non-existent,而是placeholder,sentinel。既然拼音标准已经如此,对于这样有争议的点,我更喜欢简明整齐的处理。

具体到pinyin程序,简明的方式显然是切前缀、切后缀:wén -> w -> én;而不是似乎精确高深,但既让普通用户莫名其妙(纯瞎猜)、实际用途也相对较小(仍然是猜)的:wén -> -> uén。这用程序处理起来也费劲呀……

所以,是不是可以考虑改用上面蠢萌易懂,又不易出错的方式,另外面向热爱零声母的高级用户,增加一个-0选项,对应于目前的输出结果,也算是求仁得仁,least surprise了。

mozillazg commented 7 years ago

@wdscxsj 这个问题确实是普通用户可能会经常问到的问题。

命令行工具的话,可以考虑修改默认行为以及加个 -0 选项。 包的话,因为 go 的包管理无法区分版本,所以不能修改默认行为,可以考虑加个选项控制是否支持零声母功能(默认启用):

// ZeroConsonant: 是否支持拼音标准中的零声母标准
var ZeroConsonant = true
// or
var SilentInitial = true

@gumblex @Artoria2e5 @hotoo 你们对 @wdscxsj 的意见有啥想法不?

hotoo commented 7 years ago

@wdscxsj 说的很有道理,零声母确实是比较特殊的存在,虽然可能是正确的,但在这里并没什么用。

mozillazg commented 7 years ago

最近比较忙没时间修改,欢迎提交 PR

suntong commented 7 years ago

@wdscxsj, so you agree that the best and easiest understandable way is to cut like the following?

简明的方式显然是切前缀、切后缀:wén -> w -> én

I kind of agree, at least that's what I learned when I was at school. Also, found my reference on hanyupinyin.cn, it says,

声母表: 声母:23个。分别是:b p m f d t n l g k h j q x zh ch sh r z c s y w 。

I.e., both y and w are considered 声母 at hanyupinyin.cn.

I'll use this way to fix my cc-pinyin.

suntong commented 7 years ago

详见: 汉语拼音方案 【韵母表】备注 (4)

That link is gone.

I found the following, from zh.wikisource.org. Just FTR.

(4)i 行的韵母,前面没有声母的时候,写成yi(衣), ya(呀), ye(耶), yao(腰),you(忧),yan(烟),yin(因),yang(央),ying(英),yong(雍)。u 行的韵母,前面没有声母的时候,写成wu(乌), wa(蛙), wo(窝), wai(歪),wei(威),wan(弯),wen(温),wang(汪),weng(翁)

Hope it is the same as you quoted.

wdscxsj commented 7 years ago

@wdscxsj, so you agree that the best and easiest understandable way is to cut like the following?

Absolutely. Thanks for the fix.

That link is gone.

The new link is here. See p. 4 of the PDF. After 60 years it's still the gold standard. Happy to see something so stable in our motherland. :smile_cat:

suntong commented 7 years ago

@wdscxsj, thanks.

I've fixed it in my cc-pinyin, and welcome you to test out my new cc2py

Note that cc2py does support 零声母, but undocumented.

$ cc2py "中国人的〖中国银行〗,很.行.。"
zhong guo ren de 〖zhong guo yin xing 〗,hen .xing .。

$ cc2py -t 3 "中国人的〖中国银行〗,很.行.。"
zhōng guó rén de 〖zhōng guó yín xíng 〗,hěn .xíng .。

$ cc2py -t 3 -l 9 "中国人的〖中国银行〗,很.行.。"
ōng uó én e 〖ōng uó ín íng 〗,ěn .íng .。

$ cc2py -t 2 -l 9 "中国人的〖中国银行〗,很.行.。"
o1ng uo2 e2n e 〖o1ng uo2 i2n i2ng 〗,e3n .i2ng .。

$ cc2py -h 
Chinese-Character to Pinyin converter
built on 2017-05-03

Converter Chinese to pinyin in different ways

Options:

  -h, --help            display help information
  -i, --in              the Chinese text file to read from (or stdin)
            if not specified, read from command line instead
  -t, --tone            tone selection
              0: normal. mnemonic~ nothing
              1: tone at the end. mnemonic~ single sided
              2: tone after yunmu. mnemonic~ double sided
              3: tone on yunmu. mnemonic~ fancy
  -l, --truncate        select only part of the pinyin
              0: normal. mnemonic~ nothing truncated
              1: leave first char. mnemonic~ one
              2: leave first shengmu. mnemonic~ might be two
              9: leave only yunmu. mnemonic~ last
  -s, --separator[= ]   separator string between each pinyin
  -p, --polyphone       polyphone support, output each polyphone pinyin available
  -c, --capitalized     capitalized each pinyin word