Davlatkhudzha / sunpinyin

Automatically exported from code.google.com/p/sunpinyin
0 stars 0 forks source link

关于部分汉字无法通过 sunpinyin 输入的解决方案 #271

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
已经有若干人提出部分汉字用 sunpinyin 
中即使在大字符集下也无法输入的问题,这一直没有得到解��
�。
根据我对 sunpinyin 
中使用的统计语言模型的理解,这个问题似乎是在训练语言��
�型时因为词表中单字不全造成的。
而从我所知道的所有情况来看,无法打出来的字都没有以单��
�形式出现在最先的词表(http://open-gram.googlecode.com/files/dict.utf
8.tar.bz2)中出现,这正好印证了上述的猜测。

因此,我觉得,可以将 GBK 和 GB 18030 
字符集的并集(前者似乎并不是后者的一个子集,而是另有��
�些字符)和 Unicode 
字符集中都包括而在原来的词表中没有以单字出现过的所有��
�字加入词表中(字的频率可以从 Unihan 
数据库获得;在数据库中查不到的就设为一个很小的值,比��
� 100 或更小)。
然后,用这样生成的新词表来训练语言模型。这样就可以保��
�,GB 18030 和 GBK 中任何的罕见字只要包括在 Unicode 
字符集中,都能在最终的语言模型中有记录,从而可以用 
sunpinyin 输入。

最后,非常抱歉重复在这里发刚在 open-gram 
项目里发过的东西,主要还是因为觉得在这里可能更容易让��
�题尽早解决。
在 open-gram 发的那个版本见 
http://code.google.com/p/open-gram/issues/detail?id=7#c1。

Original issue reported on code.google.com by CasperVector on 28 Jul 2011 at 1:58

GoogleCodeExporter commented 8 years ago
自己折腾了一天,大概把问题解决了。
此处是直接在 dict.utf8 上 patch,见附件中的 sunpinyin-dict.patch。

具体过程是先打上 sunpinyin-dict-fixtypo.patch 
以修正少量的输入错误,然后将 dict.utf8 中所有的 lue、nue 
替换成 lve、nve(注:这一系列 patch 是和 Issue 87 
的补丁同时做的,见 
http://code.google.com/p/sunpinyin/issues/detail?id=87),最后用 
sunpinyin-dict-extend.py 将 Unihan 数据库(因此需要 
Unihan.zip,可以从 unicode.org 下载)中的汉字导入到 dict.utf8 
中。

以上步骤的细节详见附件中的 Makefile,这些操作对 dict.utf8 
施加的改变的总和就是 sunpinyin-dict.patch。

Original comment by CasperVector on 15 Aug 2011 at 6:03

GoogleCodeExporter commented 8 years ago
之前的 python 脚本写得有点问题,现在是修正之后的版本……

Original comment by CasperVector on 16 Aug 2011 at 7:35

Attachments:

GoogleCodeExporter commented 8 years ago
针对新版本的 sunpinyin(e1fe9bce13,2012-2-21)和 Unihan 
数据库(Unicode 6.1.0,2012-01-24)的脚本更新见附件。

Original comment by CasperVector on 4 Mar 2012 at 1:53

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
非常感谢你的patch,能否移植到python 2.x的版本?

Original comment by find...@gmail.com on 4 Mar 2012 at 2:07

GoogleCodeExporter commented 8 years ago
我看看,似乎工作量应该不大……

Original comment by CasperVector on 4 Mar 2012 at 2:20

GoogleCodeExporter commented 8 years ago
终于改完了,全是在和 python2 的 unicode 支持在做各种斗争。
python 的 2/3 互换真是烦死了 = =b

Original comment by CasperVector on 4 Mar 2012 at 4:33

Attachments:

GoogleCodeExporter commented 8 years ago
Fixed in [https://github.com/sunpinyin/open-gram git] and 
[http://code.google.com/p/open-gram/downloads/list downloads].

Original comment by CasperVector on 26 Aug 2012 at 5:59