Ubuntu下快速配置ibus-libpinyin词库

ibus-libpinyin

相关作者提供了很多已经制作好的词库。我在此做一个总结:

我们就利用这三者扩充词库。第一个数学词库提供了 “用户lua脚本“和 Raw txt 文件,但是 txt 文件是反着的。所以我们写了个 cpp 来简单转换一下。

#include <iostream>
#include <string>
#include <fstream>
#include <sstream>

using namespace std;

int main()
{
    ifstream fs_in("./raw.txt");
    ofstream fs_out("./math.txt");
  
    string line;
    while(getline(fs_in,line))
    {
        istringstream str_fs(line);
        string second; str_fs >> second;
        string first; str_fs >> first;
    
        fs_out << first << " " << second << endl;
    }

    return 0;
}

得到的 math.txt 我本以为可以直接导入使用的,但是并不行。所以只能采用导入 lua 脚本的方式。

完成导入只是第一步。每个人的输入习惯是不一样的,所以 libpinyin 的词库是有词频功能的,但是我们导入的词库里是没有这个数据的。所以随着输入,这个数据就会被系统慢慢补充上,我们要做的就是定时把词库导出来。

posted @ 2025-07-12 21:32  7hu95b  阅读(106)  评论(0)    收藏  举报