{"action":"opened","issue":{"url":"https://api.github.com/repos/flyerhzm/chinese_pinyin/issues/19","labels_url":"https://api.github.com/repos/flyerhzm/chinese_pinyin/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/flyerhzm/chinese_pinyin/issues/19/comments","events_url":"https://api.github.com/repos/flyerhzm/chinese_pinyin/issues/19/events","html_url":"https://github.com/flyerhzm/chinese_pinyin/issues/19","id":90074729,"number":19,"title":"pinyin-utf8.dat 里面的 5 是什么意思","user":{"login":"wittyfox","id":3840198,"avatar_url":"https://avatars.githubusercontent.com/u/3840198?v=3","gravatar_id":"","url":"https://api.github.com/users/wittyfox","html_url":"https://github.com/wittyfox","followers_url":"https://api.github.com/users/wittyfox/followers","following_url":"https://api.github.com/users/wittyfox/following{/other_user}","gists_url":"https://api.github.com/users/wittyfox/gists{/gist_id}","starred_url":"https://api.github.com/users/wittyfox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wittyfox/subscriptions","organizations_url":"https://api.github.com/users/wittyfox/orgs","repos_url":"https://api.github.com/users/wittyfox/repos","events_url":"https://api.github.com/users/wittyfox/events{/privacy}","received_events_url":"https://api.github.com/users/wittyfox/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-22T11:29:25Z","updated_at":"2015-06-22T11:29:25Z","closed_at":null,"body":"tone_index 1 2 3 4 分别是 4 个声，5 是什么？而且有 91 个有 5.\r\n\r\n如果 `tone_index` 是 5 的话，下面代码就会出错\r\n\r\n```ruby\r\ntone_index = pinyin[-1].to_i\r\npinyin = pinyin[0...-1]\r\n%w(a o e i u v).each { |v|\r\n  break if pinyin.tr! v, TONE_MARK[v.to_sym][tone_index]\r\n}\r\n```\r\n代码来自 (https://github.com/flyerhzm/chinese_pinyin/blob/master/lib/chinese_pinyin.rb#L86-L90)\r\n\r\n因为每个 `TONE_MARK[v.to_sym]` 都只有 5 个元素，因此会取到 `nil`，再进行 `tr!` 就会报错。\r\n\r\n有些字的第一个拼音的 `tone` 不是 5，所以不会出问题。但也有不少字的第一个拼音的 `tone` 是 5，\r\n\r\n```bash\r\nawk '$2~/5/{print $1,$2}' data/pinyin-utf8.dat\r\n㟷 da5\r\n了 le5\r\n们 men5\r\n們 men5\r\n吗 ma5\r\n吧 ba5\r\n吶 ne5\r\n呗 bei5\r\n哟 yo5\r\n```\r\n\r\n这些字转成拼音都会报错.\r\n\r\n```ruby\r\nPinyin.t('呗', tonemarks: true)\r\n\r\n# : in `tr!': no implicit conversion of nil into String (TypeError)\r\n```"}}