Ubuntu22/windows10下ibus-rime/rime输入法实现用户自定义短语(phrase) #中州韵 #鼠鬚管 #小狼毫 #RIME #输入法 #双拼 #希腊字母 #数学符号


前言

在win10上使用搜狗拼音输入法还是比较方便的。 但是在Ubuntu22上使用LibPinyin或者Linux版本的搜狗输入法体验感不是很好。 为了解决批量添加用户自定义短语(phrase.txt)的问题,故而采用了rime。

個人迫切需要自定義短語的原因是我使用的中文輸入方法不太主流。輸入中文標點符號是採用拼音的方式輸入的

例如(下面的編碼標準是小鶴雙拼):
“,”=dz
“。”=ju
“σ”=sigma
“ω”=omiga
“Ω”=omigaa
“ㄣ”=ffff
“ㄈ”=fff
“%RH”=uidu
“℃”=ueuidu
……

好處是顯而易見的,手指減少了活動範圍,從不靈活的無名指和小指上把活動中心轉移到了食指和中指上。心裏讀的這種語言性思考方式得到了連續性完善(事實上當需要輸入某些符號的時候,並不會再去真的讀一邊這個符號的拼音,而是如同直接按下符號鍵一樣直接本能反應。)
其次是在輸入數學符號等奇形怪狀的字符時更加便捷而不再需要像word樣打開插入表或者按V1打開符號表。


下面是步驟講解

ubuntu22部署RIME自定义短语

步驟一、安裝ibus-rime

自行檢索

步驟二、添加用戶自定義短語文件

打開終端輸入

sudo cd ~/.config/ibus/rime/
sudo touch Custom_phrase.txt
sudo gedit Custom_phrase.txt

打開了Custom_phrase.txt這個文檔

按照如下的格式,輸入你想要的短語。

# 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

#反切符號
ㄚ	aaaa	1
ㄅ	bbb	1
巾	bbbb	1	#in
ㄘ	ccc	1
ㄠ	cccc	1
ㄉ	ddd	1
ㄞ	dddd	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	psi	1
ω	omega	1

#常用字詞
即	ji	1

#標點符號、數學符號、邏輯符號
%	bdffbi	1
?	cyzd	1
≥	dayudgyu	1
:	dkyi	1
·	dmig	1
、	dy	1
,	dz	1
;	ff	1
?	ho	1
×	iaig	1
·	jmge	1
。	ju	1
……	lt	1
:	mc	1
——	pove	1
‰	qmffbi	1
 	qrks	1	#全角空格
?	rfmbbi	1
?	rfyi	1
∴	soyi	1
!	tj	1
├	tvde	1	#推得
℃	ueuidu	1
%RH	uidu	1
~	vi	1	#至
?	wf	1
≤	xnyudgyu	1
“”	yb	1
∵	ybww	1
⊕	yiho	1	#異或
≈	ytdgyu	1
&	yu	1
【】	yuww	1	#魚尾括號


保存再退出。

步驟三

之後再在終端輸入

sudo cd ~/.config/ibus/rime/buildbuild
sudo gedit double_pinyin_flypy.schema.yaml

查找這一段

translators:
- punct_translator

在其後添加一行

- table_translator@custom_phrase

得到如下

translators:
- punct_translator
- table_translator@custom_phrase

再在文件末尾添加下面這段

custom_phrase: 
  dictionary: luna_pinyin
  user_dict: Custom_phrase
  db_class: stabledb
  enable_completion: false
  enable_sentence: false
  initial_quality: 1

其中

  dictionary: luna_pinyin
  user_dict: Custom_phrase

第一行是明月拼音的詞庫

第二行是用戶自定義短語詞庫,也是剛纔所創建的文件。

最後,右上角輸入法圖標,喚出輸入法菜單進行重新部署即可使用。

在这里插入图片描述
圖1、喚出輸入法菜單進行重新部署

下面附上我的double_pinyin_flypy.schema.yaml文件內容

__build_info:
  rime_version: 1.7.3
  timestamps:
    default: 1635007600
    default.custom: 1696306719
    double_pinyin_flypy.custom: 0
    double_pinyin_flypy.schema: 1547994611
    key_bindings: 1635007600
    key_bindings.custom: 0
    punctuation: 1635007600
    punctuation.custom: 0
engine:
  filters:
    - simplifier
    - uniquifier
  processors:
    - ascii_composer
    - recognizer
    - key_binder
    - speller
    - punctuator
    - selector
    - navigator
    - express_editor
  segmentors:
    - ascii_segmentor
    - matcher
    - abc_segmentor
    - punct_segmentor
    - fallback_segmentor
  translators:
    - punct_translator
    - table_translator@custom_phrase
    - reverse_lookup_translator
    - script_translator
key_binder:
  bindings:
    - {accept: "Control+p", send: Up, when: composing}
    - {accept: "Control+n", send: Down, when: composing}
    - {accept: "Control+b", send: Left, when: composing}
    - {accept: "Control+f", send: Right, when: composing}
    - {accept: "Control+a", send: Home, when: composing}
    - {accept: "Control+e", send: End, when: composing}
    - {accept: "Control+d", send: Delete, when: composing}
    - {accept: "Control+k", send: "Shift+Delete", when: composing}
    - {accept: "Control+h", send: BackSpace, when: composing}
    - {accept: "Control+g", send: Escape, when: composing}
    - {accept: "Control+bracketleft", send: Escape, when: composing}
    - {accept: "Control+y", send: Page_Up, when: composing}
    - {accept: "Alt+v", send: Page_Up, when: composing}
    - {accept: "Control+v", send: Page_Down, when: composing}
    - {accept: ISO_Left_Tab, send: "Shift+Left", when: composing}
    - {accept: "Shift+Tab", send: "Shift+Left", when: composing}
    - {accept: Tab, send: "Shift+Right", when: composing}
    - {accept: minus, send: Page_Up, when: has_menu}
    - {accept: equal, send: Page_Down, when: has_menu}
    - {accept: comma, send: Page_Up, when: paging}
    - {accept: period, send: Page_Down, when: has_menu}
    - {accept: "Control+Shift+1", select: .next, when: always}
    - {accept: "Control+Shift+2", toggle: ascii_mode, when: always}
    - {accept: "Control+Shift+3", toggle: full_shape, when: always}
    - {accept: "Control+Shift+4", toggle: simplification, when: always}
    - {accept: "Control+Shift+5", toggle: extended_charset, when: always}
    - {accept: "Control+Shift+exclam", select: .next, when: always}
    - {accept: "Control+Shift+at", toggle: ascii_mode, when: always}
    - {accept: "Control+Shift+numbersign", toggle: full_shape, when: always}
    - {accept: "Control+Shift+dollar", toggle: simplification, when: always}
    - {accept: "Control+Shift+percent", toggle: extended_charset, when: always}
  import_preset: default
menu:
  page_size: 5
punctuator:
  full_shape:
    " ": {commit: " "}
    "!": {commit: "!"}
    "\"": {pair: ["“", "”"]}
    "#": ["#", "⌘"]
    "$": ["¥", "$", "€", "£", "¥", "¢", "¤"]
    "%": ["%", "°", "℃"]
    "&": "&"
    "'": {pair: ["‘", "’"]}
    "(": "("
    ")": ")"
    "*": ["*", "·", "・", "×", "※", "❂"]
    "+": "+"
    ",": {commit: ","}
    "-": "-"
    .: {commit: "。"}
    "/": ["/", "÷"]
    ":": {commit: ":"}
    ";": {commit: ";"}
    "<": ["《", "〈", "«", "‹"]
    "=": "="
    ">": ["》", "〉", "»", "›"]
    "?": {commit: "?"}
    "@": ["@", "☯"]
    "[": ["「", "【", "〔", "["]
    "\\": ["、", "\"]
    "]": ["」", "】", "〕", "]"]
    "^": {commit: "……"}
    _: "——"
    "`": "`"
    "{": ["『", "〖", "{"]
    "|": ["·", "|", "§", "¦"]
    "}": ["』", "〗", "}"]
    "~": "~"
  half_shape:
    "!": {commit: "!"}
    "\"": {pair: ["“", "”"]}
    "#": "#"
    "$": ["¥", "$", "€", "£", "¥", "¢", "¤"]
    "%": ["%", "%", "°", "℃"]
    "&": "&"
    "'": {pair: ["‘", "’"]}
    "(": "("
    ")": ")"
    "*": ["*", "*", "·", "・", "×", "※", "❂"]
    "+": "+"
    ",": {commit: ","}
    "-": "-"
    .: {commit: "。"}
    "/": ["、", "/", "/", "÷"]
    ":": {commit: ":"}
    ";": {commit: ";"}
    "<": ["《", "〈", "«", "‹"]
    "=": "="
    ">": ["》", "〉", "»", "›"]
    "?": {commit: "?"}
    "@": "@"
    "[": ["「", "【", "〔", "["]
    "\\": ["、", "\\", "\"]
    "]": ["」", "】", "〕", "]"]
    "^": {commit: "……"}
    _: "——"
    "`": "`"
    "{": ["『", "〖", "{"]
    "|": ["·", "|", "|", "§", "¦"]
    "}": ["』", "〗", "}"]
    "~": ["~", "~"]
  import_preset: default
recognizer:
  import_preset: default
  patterns:
    email: "^[A-Za-z][-_.0-9A-Za-z]*@.*$"
    reverse_lookup: "`[a-z]*'?$"
    uppercase: "[A-Z][-_+.'0-9A-Za-z]*$"
    url: "^(www[.]|https?:|ftp[.:]|mailto:|file:).*$|^[a-z]+[.].+$"
reverse_lookup:
  comment_format:
    - "xform/([nl])v/$1ü/"
  dictionary: stroke
  enable_completion: true
  preedit_format:
    - "xlit/hspnz/一丨丿丶乙/"
  prefix: "`"
  suffix: "'"
  tips: "〔筆畫〕"
schema:
  author:
    - "double pinyin layout by 鶴"
    - "Rime schema by 佛振 <chen.sst@gmail.com>"
  dependencies:
    - stroke
  description: |
    朙月拼音+小鶴雙拼方案。

  name: "小鶴雙拼"
  schema_id: double_pinyin_flypy
  version: 0.18
speller:
  algebra:
    - "erase/^xx$/"
    - "derive/^([jqxy])u$/$1v/"
    - "derive/^([aoe])([ioun])$/$1$1$2/"
    - "xform/^([aoe])(ng)?$/$1$1$2/"
    - "xform/iu$/Q/"
    - "xform/(.)ei$/$1W/"
    - "xform/uan$/R/"
    - "xform/[uv]e$/T/"
    - "xform/un$/Y/"
    - "xform/^sh/U/"
    - "xform/^ch/I/"
    - "xform/^zh/V/"
    - "xform/uo$/O/"
    - "xform/ie$/P/"
    - "xform/i?ong$/S/"
    - "xform/ing$|uai$/K/"
    - "xform/(.)ai$/$1D/"
    - "xform/(.)en$/$1F/"
    - "xform/(.)eng$/$1G/"
    - "xform/[iu]ang$/L/"
    - "xform/(.)ang$/$1H/"
    - "xform/ian$/M/"
    - "xform/(.)an$/$1J/"
    - "xform/(.)ou$/$1Z/"
    - "xform/[iu]a$/X/"
    - "xform/iao$/N/"
    - "xform/(.)ao$/$1C/"
    - "xform/ui$/V/"
    - "xform/in$/B/"
    - "xlit/QWRTYUIOPSDFGHJKLZXCVBNM/qwrtyuiopsdfghjklzxcvbnm/"
  alphabet: zyxwvutsrqponmlkjihgfedcba
  delimiter: " '"
switches:
  - name: ascii_mode
    reset: 0
    states: ["中文", "西文"]
  - name: full_shape
    states: ["半角", "全角"]
  - name: simplification
    states: ["漢字", "汉字"]
  - name: ascii_punct
    states: ["。,", ".,"]
translator:
  dictionary: luna_pinyin
  preedit_format:
    - "xform/([bpmfdtnljqx])n/$1iao/"
    - "xform/(\\w)g/$1eng/"
    - "xform/(\\w)q/$1iu/"
    - "xform/(\\w)w/$1ei/"
    - "xform/([dtnlgkhjqxyvuirzcs])r/$1uan/"
    - "xform/(\\w)t/$1ve/"
    - "xform/(\\w)y/$1un/"
    - "xform/([dtnlgkhvuirzcs])o/$1uo/"
    - "xform/(\\w)p/$1ie/"
    - "xform/([jqx])s/$1iong/"
    - "xform/(\\w)s/$1ong/"
    - "xform/(\\w)d/$1ai/"
    - "xform/(\\w)f/$1en/"
    - "xform/(\\w)h/$1ang/"
    - "xform/(\\w)j/$1an/"
    - "xform/([gkhvuirzcs])k/$1uai/"
    - "xform/(\\w)k/$1ing/"
    - "xform/([jqxnl])l/$1iang/"
    - "xform/(\\w)l/$1uang/"
    - "xform/(\\w)z/$1ou/"
    - "xform/([gkhvuirzcs])x/$1ua/"
    - "xform/(\\w)x/$1ia/"
    - "xform/(\\w)c/$1ao/"
    - "xform/([dtgkhvuirzcs])v/$1ui/"
    - "xform/(\\w)b/$1in/"
    - "xform/(\\w)m/$1ian/"
    - "xform/([aoe])\\1(\\w)/$1$2/"
    - "xform/(^|[ '])v/$1zh/"
    - "xform/(^|[ '])i/$1ch/"
    - "xform/(^|[ '])u/$1sh/"
    - "xform/([jqxy])v/$1u/"
    - "xform/([nl])v/$1ü/"
  prism: double_pinyin_flypy
custom_phrase: 
  dictionary: luna_pinyin
  user_dict: Custom_phrase
  db_class: stabledb
  enable_completion: false
  enable_sentence: false
  initial_quality: 1

win10部署RIME自定义短语

第一步

在文件资源管理器中打开 % AppData%\Rime 进入「用户文件夹」,或者通过右键点击任务栏图标进入「用户文件夹」。

第二步

在用户目录中新建 Custom_phrase.txt ,输入以下内容:

#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
,	dz	1
。	ju	1
“”	yb	1
!	tj	1
……	lt	1
?	wf	1
:	mc	1

说明:

格式为:自定义短语 短语编码 排序,如:大大的小蜗牛 ddrr 1
格式中的 Tab 不能用空格代替
#no comment 之后的内容中 # 注释会失效
不宜添加过多的自定义短语,若有大量自定义短语请用用户词典

第三步

在「用户文件夹」中新建一个文件:double_pinyin_flypy.custom.yaml,一般新建一个跟正在使用的输入方案词典同名的 custom 文件。

第四步

在 double_pinyin_flypy.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

说明:不能出现多个 patch,一个文件中只能出现一次 patch,多余的需要注释掉。

第五步

重新部署输入法。

总结

參考

RIME输入法配置双拼方案(Ubuntu下基于ibus)
https://blog.csdn.net/momo1938/article/details/107013949

rime使用自定义词库的方法
https://www.xzcblog.com/post-180.html

Rime 版超强系列输入法如何加入用户词及调频
https://liangbi.gitee.io/2021/08/29/jiaci/index.html

Rime 小狼毫 五笔输入法自定义短语
https://www.eallion.com/rime-wubi/

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值