
Rime 输入法介绍
最近一直在寻找一款合适的输入法,突然搜索到了 Rime/中州韵 输入法,瞬间就被它独特的功能吸引到了,写下这边文章记录一下我的整个安装&配置过程。 Rime/中州韵输入法是一款强大的开源输入法框架,支持 Windows、MacOS、Linux、Android 等平台。
安装
各个平台的安装方法:
Linux
编译安装查看官方 wiki : https://github.com/rime/home/wiki/RimeWithIBus 使用 ibus-rime ,各发行版安装:
ArchLinu :
sudo pacman -S ibus-rime
Ubuntu/Debian :
sudo apt install ibus-rime
Fedora :
sudo dnf install ibus-rime
fcitx 安装:https://github.com/fcitx/fcitx-rime
MacOS
MacOS 上的 rime 叫鼠须管/Squirrel
,下载: https://github.com/rime/squirrel/releases
Windows
Windows 上的 rime 叫小狼毫/weasel
,下载:https://github.com/rime/weasel/releases
Android
Android 上的 rime 由第三方开发,叫同文输入法
,下载地址:https://github.com/osfans/trime/releases
配置
安装完成之后就是配置了,首先我们先选择一个适合自己的输入方案,然后了解 rime 的配置文件存储位置。目的是更好的完成一个适合自己的输入法。
输入方案可以通过东风破 plum 配置管理器安装。
东风破 plum
使用:
git clone --depth 1 https://github.com/rime/plum.gitcd plumbash rime-install :preset ###要安装的方案
各平台配置文件路径:
Linux : ~/.config/ibus/rime/
0.9.1 以下版本为 ~/.ibus/rime/
fcitx5 为 ~/.local/share/fcitx5/rime/
MacOS : ~/Library/Rime/
Windows : %APPDATA%\Rime
配置文件说明: (如不存在可手动创建) 用户资料夹 则包含为用户准备的内容,如:
-
全局设定 default.yaml
-
发行版设定 weasel.yaml squirrel.yaml build/ibus_rime.yaml
-
预设输入方案副本 <方案标识>.schema.yaml
-
※安装信息 installation.yaml
-
※用户状态信息 user.yaml
编译输入方案所产出的二进制文件:
- Rime 棱镜 <方案标识>.prism.bin
- Rime 固态词典 <词典名>.table.bin
- Rime 反查词典 <词典名>.reverse.bin
记录用户写作习惯的文件:
- ※用户词典 <词典名>.userdb/ 或 <词典名>.userdb.kct
- ※用户词典快照 <词典名>.userdb.txt、<词典名>.userdb.kct.snapshot 见于同步文件夹
以及用户自己设定的:
- ※用户对全局设定的定制信息 default.custom.yaml
- ※用户对预设输入方案的定制信息 <方案标识>.custom.yaml
- ※用户自制输入方案及配套的词典源文件
注:以上标有 ※ 号的文件,包含用户资料,您在清理文件时要注意备份!
优先级: 用户对全局设定的定制信息-default.custom.yaml > 用户对预设输入方案的定制信息-<方案标识>.custom.yaml > 全局设定-default.yaml
选择方案
在输入界面按默认快捷键:ctrl + ~
或者 F4
选择一个适合自己的方案。
部署
修改完配置文件之后配置还没有生效,用户须要使用 Rime 重新进行部署操作。
以 Linux Gnome 桌面为例:
终端部署:
touch ~/.config/ibus/rime/; ibus restart
其它平台也大同小异,一样的方式。
修改实例
修改为横排展示:
squirrel.custom.yaml
和 weasel.custom.yaml
只需要添加以下语句:
"style/horizontal": true # 横排展示
build/ibus_rime.yaml
修改:
style: horizontal: true # false 改为 true 横排展示
修改翻页按键(修改输入方案的配置 custom 文件),以明月拼音为例:
luna_pinyin.custom.yaml
修改为方括号[]
翻页:
patch: "key_binder/bindings": - { when: paging, accept: bracketleft, send: Page_Up } - { when: has_menu, accept: bracketright, send: Page_Down }
修改为加减号-+
翻页:
patch: "key_binder/bindings": - { when: paging, accept: minus, send: Page_Up } - { when: has_menu, accept: equal, send: Page_Down }
修改更多按键请参考:Rime_description
配置词库
在 default.custom.yaml
文件中开启:
"translator/enable_user_dict": true
然后在 当前输入法方案的定制文件(如我的是明月拼音简体) luna_pinyin_simp.custom.yaml
中添加内容:
patch: 'translator/dictionary': custom_dict.all
custom_dict.all
: 为字典总表文件。对应就是配置文件目录内custom_dict.all.dict.yaml
,这个可以直接自定义。
编辑 custom_dict.all.dict.yaml
:
name: custom_dict.all ##注意name和文件名一致version: "2020.6.7"sort: by_weightuse_preset_vocabulary: true# 此处为 输入法所用到的词库,既补充拓展词库的地方import_tables: - luna_pinyin # 系统基础字库 - dicts/luna_pinyin.chaizi # 拆字词库 - dicts/custom_simple # 自定义 - dicts/luna_pinyin.sougou # 搜狗词库 - dicts/luna_pinyin.xiandaihanyu # 现代汉语词典 - dicts/se_words # 互联网网络词汇 - dicts/luna_pinyin.biaoqing # 表情 - dicts/luna_pinyin.emoji # emoji Ext
luna_pinyin
是输入法方案默认的词库,其它的词库都是在dicts
目录下的。如字段 dicts/custom_simple
对应的就是 dicts
目录下的 custom_simple.dict.yaml
文件,新添加词库须要放到这个目录下并添加到 custom_dict.all.dict.yaml
文件内启用。
词库转换软件:深蓝词库转换
启用 Rime 的 Lua脚本插件
启用 Rime 的 Lua 脚本插件可实现更多功能,如时间组件等。
自编译 librime
添加 librime-lua
插件(Fedora 37)
首先安装依赖:
sudo dnf install git cmake boost boost-devel glog glog-devel leveldb-devel marisa marisa-devel opencc opencc-devel yaml-cpp yaml-cpp-devel gtest gtest-devel
然后克隆源码:
mkdir ~/workspace/cd ~/workspace/git clone https://github.com/rime/librime.gitcd librerime/bash install-plugins.sh hchunhui/librime-luacd plugins/lua/git clone https://github.com/hchunhui/librime-lua.git -b thirdparty --depth=1 thirdparty
编译安装:
# On Linux, merged buildmake merged-pluginssudo make install
ok,完成重启或者注销重新登录就行了。
启用时间日期组件&英文输入
使用 plum 安装 easy_en:
bash rime-install BlindingDark/rime-easy-en
在配置目录下创建 rime.lua
文件,写入如下内容:
time_translator = require("time")date_translator = require("date")week_translator = require("week")easy_en_translator = require("easy_en")
在配置幕下创建 lua
目录,并在目录下创建 time.lua
date.lua
week.lua
组件。
--lua语言中的注释用"--"local function translator(input, seg) if (input == "time") then --关键字更改,你也可以用or语句定义多个关键字 yield(Candidate("time", seg.start, seg._end, os.date("%H:%M"), " ")) yield(Candidate("time", seg.start, seg._end, os.date("%H点%M分"), " ")) yield(Candidate("time", seg.start, seg._end, os.date("%H:%M:%S"), " ")) yield(Candidate("time", seg.start, seg._end, os.date("%H点%M分%S秒"), " ")) endendreturn translator
--lua语言中的注释用"--"local function translator(input, seg) if (input == "date") then--------------------------------------------------------------------------------------普通日期1,类似2022年01月02日date1=os.date("%Y年%m月%d日")date_y=os.date("%Y") --取年date_m=os.date("%m") --取月date_d=os.date("%d") --取日--yield(Candidate("date", seg.start, seg._end, date1, " "))--------------------------------------------------------------------------------------普通日期2,类似2022年1月1日num_m=os.date("%m")+0num_m1=math.modf(num_m)num_d=os.date("%d")+0num_d1=math.modf(num_d)date2=os.date("%Y年")..tostring(num_m1).."月"..tostring(num_d1).."日"yield(Candidate("date", seg.start, seg._end, date2, " "))--------------------------------------------------------------------------------------普通日期3,类似1月1日num_m=os.date("%m")+0num_m1=math.modf(num_m)num_d=os.date("%d")+0num_d1=math.modf(num_d)date3=tostring(num_m1).."月"..tostring(num_d1).."日"yield(Candidate("date", seg.start, seg._end, date3, " "))yield(Candidate("date", seg.start, seg._end, os.date("%Y/%m/%d"), " "))yield(Candidate("date", seg.start, seg._end, os.date("%Y-%m-%d"), " "))--------------------------------------------------------------------------------------大写日期,类似二〇二〇年十一月二十六日date_y=date_y:gsub("%d",{["1"]="一",["2"]="二",["3"]="三",["4"]="四",["5"]="五",["6"]="六",["7"]="七",["8"]="八",["9"]="九",["0"]="〇",})date_y=date_y.."年"date_m=date_m:gsub("%d",{["1"]="一",["2"]="二",["3"]="三",["4"]="四",["5"]="五",["6"]="六",["7"]="七",["8"]="八",["9"]="九",["2"]="二",["3"]="三",["4"]="四",["5"]="五",["6"]="六",["7"]="七",["8"]="八",["9"]="九",["0"]="",})date_d=date_d.."日"if num_d1>9 thenif num_d1<19 thendate_d="十"..string.sub(date_d,4,#date_d)endendif num_d1>19 then date_d=string.sub(date_d,1,3).."十"..string.sub(date_d,4,#date_d) enddate4=date_y..date_m..date_dyield(Candidate("date", seg.start, seg._end, date4, " "))--------------------------------------------------------------------------------------英文日期 local date_d=os.date("%d") local date_m=os.date("%m") local date_y=os.date("%Y") local date_m1="" local date_m2="" if date_m=="01" then date_m1="Jan." date_m2="January" end if date_m=="02" then date_m1="Feb." date_m2="February" end if date_m=="03" then date_m1="Mar." date_m2="March" end if date_m=="04" then date_m1="Apr." date_m2="April" end if date_m=="05" then date_m1="May." date_m2="May" end if date_m=="06" then date_m1="Jun." date_m2="June" end if date_m=="07" then date_m1="Jul." date_m2="July" end if date_m=="08" then date_m1="Aug." date_m2="August" end if date_m=="09" then date_m1="Sept." date_m2="September" end if date_m=="10" then date_m1="Oct." date_m2="October" end if date_m=="11" then date_m1="Nov." date_m2="November" end if date_m=="12" then date_m1="Dec." date_m2="December" end
if date_d=="0" then symbal="st" elseif date_d=="1" then symbal="nd" elseif date_d=="2" then symbal="rd" else symbal="th" enddate5=date_m1.." "..date_d..symbal..", "..date_ydate6=date_m2.." "..date_d..symbal..", "..date_y
yield(Candidate("date", seg.start, seg._end, date5, " "))yield(Candidate("date", seg.start, seg._end, date6, " "))yield(Candidate("date", seg.start, seg._end, os.date("%Y%m%d"), " ")) endend------------------------------------------------------------------------------------return translator
--lua语言中的注释用"--"function translator(input, seg) if (input == "week") then local day_w=os.date("%w") local day_w1="" local day_w2="" local day_w3="" if day_w=="0" then day_w1="星期日" day_w2="Sunday" day_w3="Sun." end if day_w=="1" then day_w1="星期一" day_w2="Monday" day_w3="Mon." end if day_w=="2" then day_w1="星期二" day_w2="Tuesday" day_w3="Tues." end if day_w=="3" then day_w1="星期三" day_w2="Wednesday" day_w3="Wed." end if day_w=="4" then day_w1="星期四" day_w2="Thursday" day_w3="Thur." end if day_w=="5" then day_w1="星期五" day_w2="Friday" day_w3="Fri." end if day_w=="6" then day_w1="星期六" day_w2="Saturday" day_w3="Sat." end yield(Candidate("date", seg.start, seg._end, day_w1, " ")) yield(Candidate("date", seg.start, seg._end, day_w2, " ")) yield(Candidate("date", seg.start, seg._end, day_w3, " ")) yield(Candidate("week", seg.start, seg._end, os.date("%w"),"")) endendreturn translator
调试
查看日志文件:
Windows Weasel: %TEMP%
Mac OS X Squirrel: $TEMPDIR
Linux iBus: /tmp
查看日志文件(Linux):
cd /tmpcat rime.ibus.INFOcat rime.ibus.WARNINGcat rime.ibus.ERROR
推荐
推荐一个超级方便的词库配置雾凇拼音
。写完这篇后发现了这个配置,我感觉用起来挺舒服的;作者已经配置好了,跟着教程安装就行了,以下是链接:
安装或更新:全部文件
bash rime-install iDvel/rime-ice:others/recipes/full
安装或更新:所有词库文件(包含下面三个)
bash rime-install iDvel/rime-ice:others/recipes/all_dicts
安装或更新:拼音词库文件
bash rime-install iDvel/rime-ice:others/recipes/cn_dicts
安装或更新:英文词库文件
bash rime-install iDvel/rime-ice:others/recipes/en_dicts
安装或更新:opencc(emoji)
bash rime-install iDvel/rime-ice:others/recipes/opencc
评论
评论系统加载失败
无法连接到评论服务,请检查网络连接或稍后再试。