rime是一个非常优秀的输入法,linux平台下的反应速度远超搜狗,也没有隐私风险。2012年开始接触它,到后来抛弃了它,因为rime自带的词库真的太弱了,也懒得折腾。最近发现一个词库转换软件叫imewlconverter,于是发现rime导入其他输入法(比如搜狗)的词库其实还挺方便的。
要导入词库需要两个文件:
将这两个文件放置在rime的配置文件夹之后,点击rime输入法图标的“重新部署”按钮就可以了。输入“yxlm”会自动出现原来没有的候选词“英雄联盟”。
3. 怎么生成这个luna_pinyin.sogou.dict.yaml
首先安装一下imewlconverter,怎么安装就不说了。
然后下载搜狗的scel细胞词库到某个文件夹
然后在这个文件夹写一个批量转换的python脚本(见最后)。
然后运行这个脚本,就会用imewlconverter把所有的scel细胞词库文件转换成一个txt格式的词库文件,并以自定义的文件名保存,然后添加rime定义的yaml头。
拷贝文件到rime配置文件夹。
#!/usr/bin/env python
# coding=utf-8
# ============================================================
# filename : convert.py
# author : chdy.uuid@gmail.com
# modified : 2019-09-11 15:39
# descrip. :
# ============================================================
from glob import glob
import os
import shutil
if not os.path.exists(‘./output/’):
os.mkdir(‘output’)
original_files = glob(“*.scel”)
print(“—————“)
for of in original_files:
if ‘ ‘ in of:
new_fn = of.replace(‘ ‘, ‘_’)
print(‘rename “%s” to “%s”‘ % (of, new_fn))
shutil.move(of, new_fn)
of = new_fn
print(‘>> ‘, of)
print(“—————“)
original_files = glob(“*.scel”)
# print(original_files)
yaml_file = ‘luna_pinyin.sogou.dict.yaml’
command=”’imewlconverter -i:scel %s -o:rime “%s””’ % (str(original_files).strip(‘[]’).replace(‘,’, ”), yaml_file)
print(command)
os.system(command)
data = ”’—
name: luna_pinyin.sogou
version: “1.0”
sort: by_weight
use_preset_vocabulary: true
# 此处为扩充词库(基本)默认链接载入的词库
import_tables:
– luna_pinyin
– luna_pinyin.sogou
…
# 自定义词语
”’
with open(yaml_file, “r+”) as f:
old = f.read()
f.seek(0)
f.write(data)
f.write(old)
print(“Now don’t forget to copy the file to rime config folder (like ~/.config/fcitx/rime)”)
https://www.jianshu.com/p/300bbe1602d4
相关资源:韵母字典(韵母查询软件)V1.0.2免费安装版-其它代码类资源-CSDN文库
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!