-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
有什么思路实现带前缀的混输方案? #138
Comments
首先那个反查用的pinyin_simp里没有“中华人民共和国”这个词, 如果要拼音英文混输,一个想法是先建一个拼音+英文混输的方案,然后加个 或者如果没有中英文混输的需求,把它们分开,比如设置以 |
多谢了,我先学习下 另外贴下现在五笔的反查配置: reverse_lookup:
dictionary: xxx_pinyin
prefix: "z"
recognizer:
patterns:
# z模式反查拼音
reverse_lookup: "^z[a-z]*$" 纠正一点的是,反查的话没有要求五笔码表里面一定存在,如下图所示,除了前两个,后面的词在五笔码表里面都是不存在的 |
我参考了cangjie6.schema.yaml的写法,基本上能比较好地满足我的需要。 核心配置如下,前缀z切换到拼音输入,前缀Z切换到英文输入,前缀X拼音反查。 engine:
segmentors:
- affix_segmentor@pinyin
- affix_segmentor@english
- affix_segmentor@pinyin_lookup
translators:
- table_translator@english
- script_translator@pinyin
- script_translator@pinyin_lookup
filters:
- reverse_lookup_filter@pinyin_reverse_lookup
english:
tag: english
dictionary: melt_eng
prefix: Z
tips: [英语]
comment_format: # 自定义提示码
- xform/.*// # 清空提示码
pinyin:
tag: pinyin
dictionary: xxx_pinyin
prefix: z
tips: 【拼音】
pinyin_lookup:
tag: pinyin_lookup
prefix: "X"
dictionary: xxx_pinyin
tips: 【反查】
pinyin_reverse_lookup:
tags:
- pinyin_lookup
dictionary: *dict
overwrite_comment: true
recognizer:
patterns:
# X 实现拼音反查
pinyin_lookup: "X[a-z]*$"
# z开头输入拼音
pinyin: "z[a-z']*$"
# Z开关输入英文
english: "Z[a-zA-Z]*$" 但是有遇到了下述问题:
比如这种情况下,输入2
不管是英文还是拼音,如果我直接回车上屏的话,上屏的也是包含前缀字符 辛苦帮忙看下,还需要进入哪里的修改~~ 感谢 |
@plutotree 1的话,我这边差不多配置,试了是没问题的,你的配置贴完整下,engine里还有其他呢,是不是segmentors和processor少了或顺序错了什么的 2的话……其实我挺久没研究rime了,对rime本体并不很熟。不知Rime有没有,在指定Tag下才开启的key_binder,比如在 |
1知道了,是大写前缀的问题,默认Rime有一个 punctuator:
import_preset: default
# import_preset: symbols
@@ -123,6 +156,9 @@ recognizer:
patterns:
# punct: "^/([0-9]+[a-z]*|[a-z]+)$" # 注意前方需要有4个空格,跟下面对齐
reverse_lookup: "^z[a-z]*'?$" # 反查词条的正则
+ uppercase: ""
pinyin: '^\|[a-z'']*$'
english: '^Z[a-zA-Z]*$'
calculator: "^coco.*$" # 计算器 |
回车跳过前缀上屏用lua的改法,供参考 diff --git a/lua/processor_enter_skip_prefix.lua b/lua/processor_enter_skip_prefix.lua
new file mode 100644
index 0000000..854f639
--- /dev/null
+++ b/lua/processor_enter_skip_prefix.lua
@@ -0,0 +1,34 @@
+_G.kRejected, _G.kAccepted, _G.kNoop = 0, 1, 2
+
+local tags = { 'english', 'pinyin' }
+
+local function check_tag(context)
+ local composition = context.composition
+ if (not composition:empty()) then
+ local segment = composition:back()
+ for _, x in ipairs(tags) do
+ if segment:has_tag(x) then
+ return true
+ end
+ end
+ end
+ return false
+end
+
+local function processor(key, env)
+ local engine = env.engine
+ local context = engine.context
+ local repr = key:repr()
+ local input = context.input
+
+ if check_tag(context) and repr == 'Return' then
+ engine:commit_text(string.sub(input, 2))
+ context.input = ''
+ return kAccepted
+ end
+
+ return kNoop
+end
+
+return processor
+
diff --git a/wubi86_jidian.schema.yaml b/wubi86_jidian.schema.yaml
index aae7a13..f1ca905 100644
--- a/wubi86_jidian.schema.yaml
+++ b/wubi86_jidian.schema.yaml
@@ -36,6 +36,7 @@ engine:
- ascii_composer
- recognizer
- key_binder
+ - lua_processor@*processor_enter_skip_prefix
- speller
- punctuator
- selector
|
第一点是和拼音的混输
现在有五笔拼音的混输方案,但是这样重码率太高,不利于盲打。想要的是可以使用前缀比如z来实现拼音的输入,但是想要的并不是反查模式,反查只有完整输入才能出结果。
比如我输入zzhr 就可以提示中华人民 中华人民共和国,在反查模式下是需要输入完整才能提示
第二点是英文的混输 现在对于中英文混杂的内容需要频繁来回切换中英文模式很不方便,另一点也希望能有联想输入。所以用前缀的英文混输方案感觉也比较符合
比如我输入zcl 就可以提示 close clock clone等
这个需求要实现的话是需要在码表中增加前缀,还是通过lua解决呢?还是有其它更好的解决方案呢?
The text was updated successfully, but these errors were encountered: