Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ipcjs/cb527f85e027d7927ef3e42a0602ddf5 to your computer and use it in GitHub Desktop.
Save ipcjs/cb527f85e027d7927ef3e42a0602ddf5 to your computer and use it in GitHub Desktop.
Rime+小鹤双拼+颜文字+笔画混合输入方案

Rime+小鹤双拼+颜文字+笔画混合输入方案

概述

方案配置文件+详细说明:Rime+小鹤双拼+颜文字+笔画混合输入方案

实现的功能是:给小鹤双拼添加颜文字支持,直接打双拼出颜文字,支持模糊音,支持词频调整,同时不影响小鹤双拼自带的笔画反查。

要实现双拼+颜文字的功能网上已经有很多方法,但都有些弊端,这里分别简单介绍下:

  1. 反查法:新建专门的颜文字方案,配置好字典、双拼、模糊音,使用reverse_lookup_translator配置反查功能,反查字典设成颜文字字典。
    • 使用reverse_lookup_translator配置的反查功能打字时,出字的词频不会改变,且一直排在最后,不方便。还占用了笔画反查的功能。
  2. 自定义短语法:配置好自定义短语功能后,直接把颜文字\t拼音编码添加到custom_phrase.txt中。
    • 双拼下使用该方案的话,拼音编码就要使用双拼的编码,还不能用模糊音,很麻烦。
  3. 扩展词库法:使用import_tables把颜文字字典导入到luna_pinyin.dict.yaml
    • 该方案的问题是,颜文字和文字字典混合到一起去了,不能分别设置优先级,还有可能拼出颜文字和文字混合的词组。

已有的方法都用的不顺心,所以我就琢磨了这套方法:

  1. 副翻译器法:新建专门的颜文字方案(X_emoji.schema.yaml),配置好字典(X_emoji.dict.yaml)、双拼、模糊音;使用affix_segmentor@emoji+script_translator@emoji+reverse_lookup_filter@filter_emoji配置颜文字的翻译器和反查功能。(详细配置自己下下来看吧(;¬_¬))
    • 目前用的还算好,就是颜文字字典要自己慢慢积累_(:3」∠)_

Update 2020-09-23:

  1. rime/rime-emoji: Emoji / 繪文字輸入方案:这是官方的颜文字输入方案,貌似利用了和简繁转换类似的方法,可以做到类似搜狗的打字出颜文字的效果,推荐启用

关于维基词库

我目前维护了一个维基词库(最新版下载),下载后丢到小狼毫的用户文件夹下,再编辑下luna_pinyin.extended.dict.yaml就行

小狼毫、Prime、rime-gits功能对比

功能 小狼毫 Prime rime-gits
基础功能
横排
扩展词库
同步
自定义皮肤
特定进程默认英文模式
Shift上屏并切换英文模式
Other
# Rime schema
# encoding: utf-8
patch:
style/horizontal: true # 横排
schema/dependencies:
- stroke # 依赖笔画方案, 用于反查笔画
- X_emoji # 依赖颜文字方案, 用于生成颜文字固态词典, 作为副翻译器的词典
engine/segmentors: # 注意, 有顺序
- ascii_segmentor
- matcher
- affix_segmentor@emoji # 自定义的emoji标签
- abc_segmentor
- punct_segmentor
- fallback_segmentor
engine/translators:
- punct_translator
- reverse_lookup_translator # 旧的反查+翻译器, 这里用来做笔画反查
- script_translator
- table_translator@custom_phrase #自定义短语的翻译器
- script_translator@emoji # emoji翻译器
engine/filters:
- simplifier
- uniquifier
- reverse_lookup_filter@filter_emoji
# 主翻译器
translator/dictionary: luna_pinyin.extended # 字典
translator/initial_quality: 1 # 主翻译器的优先级设为1
# translator/spelling_hints: 9 # 多少字以下自动注音
# 自定义短语(相当于一个副翻译器)
custom_phrase:
dictionary: ""
user_dict: custom_phrase
db_class: stabledb
enable_completion: false
enable_sentence: false
initial_quality: 1 # 和主翻译器优先级相等
# 颜文字翻译器+反查, 前缀为yw
recognizer/patterns/emoji: "yw[a-z]*'?$"
abc_segmentor/extra_tags: # 为abc标记的段落加上emoji标签
- emoji
emoji: # emoji标签和翻译器同名, 可同时设置
tag: emoji
dictionary: "X_emoji"
tips: "【颜文字】"
closing_tips: ">"
prefix: "yw"
suffix: "'"
enable_sentence: false
initial_quality: 0.9 # 小于主翻译器优先级, 初始位于主翻译器所有匹配到的词后面, 打出过一次后会往前移, 但基本上不会到达第一位置
filter_emoji: # 反查颜文字的编码
tags: [ emoji ]
overwrite_coment: true
dictionary: "X_emoji"
# 五笔画反查, 前缀为wb
recognizer/patterns/reverse_lookup: "wb[a-z]*'?$" # 五个b开启反查
# abc_segmentor/extra_tags: # 为abc标记的段落加上反查tag, 使正常输入时也可以用反查输入法
# - reverse_lookup
reverse_lookup:
dictionary: stroke
enable_completion: true
prefix: wb # 前缀
suffix: "'" # 后缀
tips: "【五笔画】" # 提示字
closing_tips: ">"
comment_format:
- "xform/([nl])v/$1ü/"
preedit_format:
- "xlit/hspnz/一丨丿丶乙/"
# 字符库
punctuator/import_preset: my_symbols # 添加符号库, 里面的符号直接手动修改
recognizer/patterns/punct: "^/([a-z]+|[0-9]0?)$" # 触发符号库里的符号输出, 正则也可以用"^/[0-9]?[a-z]*$"
# switches:
# - name: ascii_mode
# reset: 1 # 默认“西文”
# states: ["中文", "西文"]
# - name: full_shape
# states: ["半角", "全角"]
# - name: ascii_punct
# states: [",。", ",."]
# - name: simplification
# states: ["漢字", "汉字"]
speller/alphabet: zyxwvutsrqponmlkjihgfedcba # 拼写处理器接收哪些按键; 可添加".", 让“.”也录入到输入器里面去, 防止按“.“直接出文字
speller/algebra:
- "erase/^xx$/"
- "derive/^([jqxy])u$/$1v/"
- "derive/^([aoe])([ioun])$/$1$1$2/"
# 模糊音设置.start
- derive/^([zcs])h/$1/ # zh, ch, sh => z, c, s
- derive/^([zcs])([^h])/$1h$2/ # z, c, s => zh, ch, sh
# - derive/^r/l/ # r => l
# - derive/^l/r/ # l => r
# - derive/^l/n/ # l => n
# - derive/^n/l/ # n => l
- derive/([ei])n$/$1ng/ # en => eng, in => ing
- derive/([ei])ng$/$1n/ # eng => en, ing => in
# 模糊音.end
- "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/"
# Rime schema settings
# encoding: utf-8
---
name: luna_pinyin.extended
version: "2014.05.05"
sort: by_weight
use_preset_vocabulary: true
import_tables:
- luna_pinyin
- X_zifu
# 维基词库, 下载页面: https://github.com/ipcjs/fcitx5-pinyin-zhwiki/releases/latest
# - zhwiki
...
# Rime dictionary
# encoding: utf-8
# 字典
---
name: X_emoji
version: "2016.08.18.0"
sort: by_weight # by_weight,按词频排序;original,按码表中的顺序
use_preset_vocabulary: false # 不使用rime自带词库自动生成编码
# import_tables:
# - meow_emoji
...
# 测试
颜文字词库导入成功!?? test
☛0 jiang 0
☛ jiang
☛1% jiang 1%
☛10% jiang 10%
☛100% jiang 100%
☛1 jiang 1
☛10 jiang 10
☛100 jiang 100
☛1000 jiang 1000
☛10000 jiang 10000
☛100000 jiang 100000
# 注音颜文字
(。・ω・。) meng
=.=! han
╮(╯_╰)╭ wu nai
(ಥ_ಥ) ku
(ಥ_ಥ) lei
(;′ρ`) liu kou shui
(;′ρ`) kou shui
╮( ̄▽ ̄)╭ gao xing
(`・ω・´) hao
←_← ding
→_→ ding
(;¬_¬) ding
_(:3」∠)_ tang
(╯°口°)╯(┴—┴ xian zhuo
(#-_-)┯━┯ xian zhuo
bilibili-(゜-゜)つロ乾杯~ gan bei
# 所有颜文字
(;′ρ`) yw
(ಥ_ಥ) yw
=.=! yw
(⌒▽⌒) yw
( ̄▽ ̄) yw
(=・ω・=) yw
(`・ω・´) yw
(〜 ̄△ ̄)〜 yw
(・∀・) yw
(°∀°)ノ yw
( ̄3 ̄) yw
╮( ̄▽ ̄)╭ yw
( ´_ゝ`) yw
←_← yw
→_→ yw
(<_<) yw
(>_>) yw
(;¬_¬) yw
("▔□▔)/ yw
(゚Д゚≡゚д゚)!? yw
Σ(゚д゚;) yw
Σ(  ̄□ ̄||) yw
(´;ω;`) yw
(/TДT)/ yw
(^・ω・^ ) yw
(。・ω・。) yw
(● ̄(エ) ̄●) yw
ε=ε=(ノ≧∇≦)ノ yw
(´・_・`) yw
(-_-#) yw
( ̄へ ̄) yw
( ̄ε(# ̄) Σ yw
ヽ(`Д´)ノ yw
(╯°口°)╯(┴—┴ yw
(#-_-)┯━┯ yw
_(:3」∠)_ yw
bilibili-(゜-゜)つロ乾杯~ yw
# 符号
° du
℃ she shi du
± zheng fu
Ω ou mu
→ you
✔ gou
✖ cha
# Rime dictionary
# encoding: utf-8
# Rime schema
# encoding: utf-8
schema:
schema_id: X_emoji
name: 颜文字
version: "0.20"
author:
- ipcjs <[email protected]>
description: |
从小鹤双拼改过来的,主要用来生成固态词典,供小鹤双拼引用,作为副翻译器
# dependencies:
# - stroke
switches:
- name: ascii_mode
reset: 0
states: [ 中文, 西文 ]
- name: full_shape
states: [ 半角, 全角 ]
- name: ascii_punct
states: [ ,。, ,. ]
- name: simplification
states: [ 漢字, 汉字 ]
engine:
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
# - reverse_lookup_translator
- script_translator
filters:
- simplifier
- uniquifier
speller:
alphabet: zyxwvutsrqponmlkjihgfedcba
delimiter: " '"
algebra:
- "erase/^xx$/"
- "derive/^([jqxy])u$/$1v/"
- "derive/^([aoe])([ioun])$/$1$1$2/"
# 模糊音设置
- derive/^([zcs])h/$1/ # zh, ch, sh => z, c, s
- derive/^([zcs])([^h])/$1h$2/ # z, c, s => zh, ch, sh
# - derive/^r/l/
# - derive/^l/r/
# - derive/^l/n/
# - derive/^n/l/
- derive/([ei])n$/$1ng/ # en => eng, in => ing
- derive/([ei])ng$/$1n/ # eng => en, ing => in
- "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/"
translator:
dictionary: X_emoji
# prism: double_pinyin_flypy
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ü/
# reverse_lookup:
# dictionary: stroke
# enable_completion: true
# prefix: "`"
# suffix: "'"
# tips: 〔筆畫〕
# preedit_format:
# - xlit/hspnz/一丨丿丶乙/
# comment_format:
# - xform/([nl])v/$1ü/
punctuator:
import_preset: default
key_binder:
import_preset: default
recognizer:
import_preset: default
# patterns:
# reverse_lookup: "`[a-z]*'?$"
# Rime dictionary
# encoding: utf-8
# 字符字典, 放英文单词, 汉字
---
name: X_zifu
version: "2013.07.11.2"
sort: by_weight
use_preset_vocabulary: false
...
特殊词库导入成功!?? test
# 英文单词
Android android
iPhone iphone
iPad ipad
iOS ios
Play play
Rime rime
Prime prime
Project project
QQ qq
link link
Google google
WiFi wifi
UI ui
# 特殊符号
⇻ suspend
© companion
# 汉字
狛 bo
原型链 yuan xing lian
鋈 wo jing
又双叒叕 you you you you
春埼 chun qi
@Aquaakuma
Copy link

感觉没应用上啊,放文件夹部署了,模糊音和emoji都没用。

@ipcjs
Copy link
Author

ipcjs commented Sep 23, 2020

@Tut123456 在输入法设定里面有没有把 小鹤双拼 打上钩?

@ipcjs
Copy link
Author

ipcjs commented Sep 23, 2020

@Tut123456 好像少了一两个文件😓️,你重新下载所有的文件再试试?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment