scim的词库比较旧,很多词都不能打出来,所以想把windows下的输入法中的词库导进来。在网上找了很多方法,基本上都过时不能用了。
http://forum.ubuntu.org.cn/viewtopic.php?t=99877中说可以直接使用极点五笔和万能五笔的bin文件,但我试过了最新版的,不行。可能旧版的可以,但我还是希望用最新的词库。这篇文章中的主要方法是这样的,在windows中安装好极点五笔或万能五笔后,使用root账号把windows下输入法安装目录中的bin文件拷贝到/usr/share/scim/tables,然后使用pkill scim && scim -d 重启scim。
我是按http://forum.ubuntu.org.cn/viewtopic.php?f=8&t=125858&start=0五楼的方法成功的。不过找输入法的txt码表找了好久,后来是偶然发现极点五笔7.12可以导出码表,在“管理工具”->“词库工具”->“词库生成与维护”,点导出就可以了。导出过程很慢,要花好几分钟。导出的文件放在“我的文档/freeime.txt”。
有了txt的码表就好办了,先把scim五笔中旧的码表导出来:进这个目录 usr/share/scim/tables,然后执行scim-make-table Wubi.bin -o Wubi.txt。然后把两个码表综合一下,我是使用PHP脚本来处理的,scim中没有的词就加进去,默认词频是1000:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php $org = file_get_contents("Wubi.txt"); $new = file_get_contents("freeime.txt"); //$org = substr($org, 0, 1000); $gz1 = '/([a-z]+)\s(.*)\s([0-9]+)/'; preg_match_all($gz1, $org, $u1); //print_r($u1);exit; $codeList = array(); foreach($u1[2] as $k=>$v){ $codeList[$u1[1][$k]][] = array('char'=>$v, 'f'=>$u1[3][$k]); } //print_r($codeList); $new = iconv('unicode', 'utf-8', $new); //$new = substr($new, 0, 1000); //echo $new; $gz2 = '/([a-z]+)\s(.+)/'; preg_match_all($gz2, $new, $u2); //print_r($u2); foreach($u2[2] as $k=>$v){ $charList = explode(' ', $v); $code = trim($u2[1][$k]); foreach($charList as $char){ $char = trim($char); if (isset($codeList[$code])){ $isExist = false; foreach($codeList[$code] as $v1){ if ($char == $v1['char']){ $isExist = true; break; } } if($isExist){ continue; } } $codeList[$code][] = array('char'=>$char, 'f'=>1000); } } //print_r($codeList); $tableStr = ''; foreach($codeList as $k=>$v){ $code = $k; foreach($v as $charArray){ $tableStr .= "$code\t{$charArray['char']}\t{$charArray['f']}\n"; } } //echo $tableStr; file_put_contents('newTable.txt', $tableStr); echo 'done'; ?>
综合好码表后,执行
scim-make-table Wubi.txt -b -o /usr/share/scim/tables/Wubi.bin
重新生成bin文件,覆盖原来的,再执行pkill scim && scim -d 重启scim。
不过我的OpenSuse11.3这样重启scim后不能用输入法了,要注销了重新登录才行。
另外,默认情况下scim不能动态调整词频,修改txt状态的码表中的
DYNAMIC_ADJUST = FALSE
成
DYNAMIC_ADJUST = TRUE
再重新生成bin就可以了。好像在“SCIM设置”->“通用码表管理”->“码表管理”->“属性”里面也可以设置,但有时候行,有时候是灰色不可设置的。