本文主要是介绍Ubuntu 22 下ibus-rime實現用戶自定義短語(phrase),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文章目录
- 前言
- 步驟一、安裝ibus-rime
- 步驟二、添加用戶自定義短語文件
- 步驟三
- 总结
- 參考
前言
在win10上使用搜狗拼音输入法还是比较方便的。 但是在Ubuntu22上使用LibPinyin或者Linux版本的搜狗输入法体验感不是很好。 为了解决批量添加用户自定义短语(phrase.txt)的问题,故而采用了rime。
個人迫切需要自定義短語的原因是我使用的中文輸入方法不太主流。輸入中文標點符號是採用拼音的方式輸入的
例如(下面的編碼標準是小鶴雙拼):
“,”=dz
“。”=ju
“σ”=sigma
“ω”=omiga
“Ω”=omigaa
“ㄣ”=ffff
“ㄈ”=fff
“%RH”=uidu
“℃”=ueuidu
……
好處是顯而易見的,手指減少了活動範圍,從不靈活的無名指和小指上把活動中心轉移到了食指和中指上。心裏讀的這種語言性思考方式得到了連續性完善(事實上當需要輸入某些符號的時候,並不會再去真的讀一邊這個符號的拼音,而是如同直接按下符號鍵一樣直接本能反應。)
其次是在輸入數學符號等奇形怪狀的字符時更加便捷而不再需要像word樣打開插入表或者按V1打開符號表。
下面是步驟講解
步驟一、安裝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 1
ㄜ eeee 1
ㄈ fff 1
ㄣ ffff 1
ㄍ ggg 1
ㄥ gggg 1
ㄏ hhh 1
ㄤ hhhh 1
ㄔ iii 1
ㄧ iiii 1
ㄐ jjj 1
ㄢ jjjj 1
ㄎ kkk 1
丁 kkkk 1 #ing
夬 kkkk 2 #uai
ㄌ lll 1
羊 llll 1 #iang
王 llll 2 #uang
ㄇ mmm 1
チ mmmm 1
ㄋ nnn 1
小 nnnn 1 #iao
ㄛ oooo 1
火 oooo 2 #uo
ㄆ ppp 1
ㄝ pppp 1
ㄑ qqq 1
牛 qqqq 1 #iu
ㄖ rrr 1
ツ rrrr 1 #uan
ㄙ sss 1
エ ssss 1 #ong
冂 ssss 2 #iong
ㄊ ttt 1
ヨ tttt 1 #ue
ㄕ uuu 1
ㄨ uuuu 1
ㄓ vvv 1
ㄩ vvvv 1
氺 vvvv 2 #ui
ㄟ wwww 1
ㄒ xxx 1
ヱ xxxx 1 #ia
爪 xxxx 1 #ua
文 yyyy 1 #un
ㄗ zzz 1
ㄡ zzzz 1#希臘字母
#小寫
#大寫(尾巴雙寫)
Α alphaa 1
Β betaa 1
Γ gammaa 1
Δ deltaa 1
Ε epsilonn 1
Ζ zetaa 1
Η etaa 1
Ι iotaa 1
Κ kappaa 1
Λ lambdaa 1
Μ muu 1
Ν nuu 1
Ξ xii 1
Ο omicronn 1
Π pii 1
Ρ rhoo 1
Σ sigmaa 1
Τ tauu 1
Υ upsilonn 1
Φ phii 1
Χ chii 1
Ψ psii 1
Ω omegaa 1
α alpha 1
β beta 1
γ gamma 1
δ delta 1
ε epsilon 1
ζ zeta 1
η eta 1
ι iota 1
κ kappa 1
λ lambda 1
μ mu 1
ν nu 1
ξ xi 1
ο omicron 1
π pi 1
ρ rho 1
σ sigma 1
τ tau 1
υ upsilon 1
φ phi 1
χ chi 1
ψ 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 1qrks 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_pinyinuser_dict: Custom_phrasedb_class: stabledbenable_completion: falseenable_sentence: falseinitial_quality: 1
其中
dictionary: luna_pinyinuser_dict: Custom_phrase
第一行是明月拼音的詞庫
第二行是用戶自定義短語詞庫,也是剛纔所創建的文件。
最後,右上角輸入法圖標,喚出輸入法菜單進行重新部署即可使用。
圖1、喚出輸入法菜單進行重新部署 |
下面附上我的double_pinyin_flypy.schema.yaml文件內容
__build_info:rime_version: 1.7.3timestamps:default: 1635007600default.custom: 1696306719double_pinyin_flypy.custom: 0double_pinyin_flypy.schema: 1547994611key_bindings: 1635007600key_bindings.custom: 0punctuation: 1635007600punctuation.custom: 0
engine:filters:- simplifier- uniquifierprocessors:- ascii_composer- recognizer- key_binder- speller- punctuator- selector- navigator- express_editorsegmentors:- ascii_segmentor- matcher- abc_segmentor- punct_segmentor- fallback_segmentortranslators:- 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: defaultpatterns: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: strokeenable_completion: truepreedit_format:- "xlit/hspnz/一丨丿丶乙/"prefix: "`"suffix: "'"tips: "〔筆畫〕"
schema:author:- "double pinyin layout by 鶴"- "Rime schema by 佛振 <chen.sst@gmail.com>"dependencies:- strokedescription: |朙月拼音+小鶴雙拼方案。name: "小鶴雙拼"schema_id: double_pinyin_flypyversion: 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: zyxwvutsrqponmlkjihgfedcbadelimiter: " '"
switches:- name: ascii_modereset: 0states: ["中文", "西文"]- name: full_shapestates: ["半角", "全角"]- name: simplificationstates: ["漢字", "汉字"]- name: ascii_punctstates: ["。,", ".,"]
translator:dictionary: luna_pinyinpreedit_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_pinyinuser_dict: Custom_phrasedb_class: stabledbenable_completion: falseenable_sentence: falseinitial_quality: 1
总结
無
參考
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
这篇关于Ubuntu 22 下ibus-rime實現用戶自定義短語(phrase)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!