Last active
April 21, 2026 10:52
-
-
Save lotem/5440677 to your computer and use it in GitHub Desktop.
Rime 自定義短語文件樣例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Rime table | |
| # coding: utf-8 | |
| #@/db_name custom_phrase.txt | |
| #@/db_type tabledb | |
| # | |
| # 用於【朙月拼音】系列輸入方案 | |
| # 【小狼毫】0.9.21 以上 | |
| # | |
| # 請將該文件以UTF-8編碼保存爲 | |
| # Rime用戶文件夾/custom_phrase.txt | |
| # | |
| # 碼表各字段以製表符(Tab)分隔 | |
| # 順序爲:文字、編碼、權重(決定重碼的次序、可選) | |
| # | |
| # 雖然文本碼表編輯較爲方便,但不適合導入大量條目 | |
| # | |
| # 出現在以下這行註釋之後的 # 不再識別爲註釋: | |
| # no comment | |
| 中州韻輸入法引擎 rime 3 | |
| Rime Input Method Engine rime 2 | |
| https://rime.im/ rime 1 | |
| 星際我爭霸 starcraft | |
| tassadar@protoss.net email |
不能使用.吗? 用来简写一些常用的域名, 比如 github.com g.h 期待只需要输入g.h就能输出github.com, 目前看来是只要包含了.就不能正确输出, 好像是,.被翻页占用的原因
还有个需求就是能用变量吗? 比如输出当前日期时间比较方便
emoji不能使用对吗?
❌ xx 1
符号怎么使用啊
支持换行了吗?
五笔_拼音有办法用这个功能不
custom_phrase里的格式是一样的,需要额外写一个wubi_pinyin.custom.yaml在用户文件夹里,代码写如下:
patch:
engine/translators:
- punct_translator
- reverse_lookup_translator
- script_translator
- table_translator@custom_phrase
- table_translator
custom_phrase:
dictionary: ""
user_dict: custom_phrase
db_class: stabledb
enable_completion: false
enable_sentence: false
initial_quality: 1
为什么文件里权重写了1,但是实际使用的时候有概率掉到3上呢
(不是那种有概率,就是有的正常,有的掉到3上,而且是确定的哪几个正常哪几个不对)
奇怪
rime 自定义短语支持 换行吗?
rime 自定义短语支持 换行吗?
同问,写的 \n 原样输出了
参考 https://github.com/hchunhui/librime-lua/blob/master/sample/lua/single_char.lua,自己写了个 lua 脚本,支持替换 \\n 为 \n,目前只有这个需求,如果有其他的需要替换可以自己修改代码:
-- lua/new_line.lua
-- 在方案补丁中新增 'engine/filters/@before last': lua_filter@*new_line
local M = {}
function M.init(env)
end
function M.func(input)
for cand in input:iter() do
-- 处理换行符 如果只需要 custom_phrase 里面的转换,判断一下 cand.type 是否为 user_table 就可以了
if (cand.text:match("\\n")) then
local replaced_text = string.gsub(cand.text, "\\n", "\n")
-- 生成新候选(关键!)候选文字不能直接修改,注释可以
local new_cand = Candidate(
cand.type,
cand.start,
cand._end,
replaced_text, -- 你想要的文字
cand.comment -- 你想要的注释
)
-- 保留原权重(不影响排序)
new_cand.quality = cand.quality
yield(new_cand)
else
yield(cand)
end
end
end
return M
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
同问:如何换行呢?
希望增加换行功能,比如用\n来给自定义短语换行等等。