Skip to content
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

feat: 部件拆字及辅码 #643

Merged
merged 11 commits into from
Jan 29, 2024
Merged

feat: 部件拆字及辅码 #643

merged 11 commits into from
Jan 29, 2024

Conversation

iDvel
Copy link
Owner

@iDvel iDvel commented Jan 26, 2024

功能简介

拼字

以 uU 开头来拼字,会得到部件拆字词库中的所有字,包含生僻字。
因为这种方式反查时引导符会消失,如果单用一个字母则影响其他的正常拼写,或可改为以一个非字母符号作为前缀。

示例:uUshuijin → 淦,uUxixi → 囍,uUlonglong → 龖、𱍂、龘
还可以直接造句:
2024-01-28-002375

辅码查询

`(反引号)开启辅码查询,只会对当前拼音方案的字进行筛选。
` 只在中间起作用,同时新增了一个 auto_commit_single_punct.lua 确保 ` 仍然可以直接上屏。

单字示例:gan`shui 得到拼音为 gan 且偏旁为三点水的「淦、泔、澉 ……」,gan`shuijin 直接得到「淦」。
句子示例:
2024-01-28-002379

支持双拼

相比两分写死的编码,部件拆字支持双拼的拼写规则,需要在 radical_pinyin.schema.yamlspeller/algebra 下选择对应的拼写运算。
2024-01-28-002380

@iDvel
Copy link
Owner Author

iDvel commented Jan 26, 2024

@mirtlecn 你看看,应该是没问题👌,然后我好补全双拼的和相关注释。

目前发现个小问题就是 u 开头的反查仍然会被简繁切换给应用到,traditionalize/excluded_types: [ reverse_lookup, radical_lookup ] 似乎不起作用。

还有设置为 u 开头反查,和两分不一样的是,在输入后 u 会消失,这个好像也没有设置项。

@mirtlecn
Copy link
Collaborator

我来给你这个分支提个 pr 吧,你参考一下

@iDvel
Copy link
Owner Author

iDvel commented Jan 27, 2024

@mirtlecn
如果在辅码查询时屏蔽掉不相干的候选项是否更好?
目前 gan`shui 时,除了显示「淦、泔、澉」,后续的 gan 「干、感……」等等也会显示。
既然用了辅码,可能就是要精确查询的。

示例:

2024-01-27-002372

2024-01-27-002373

改了一下逻辑你看看。

@mirtlecn
Copy link
Collaborator

都行

lua/search.lua Outdated Show resolved Hide resolved
rime_ice.schema.yaml Outdated Show resolved Hide resolved
rime_ice.schema.yaml Outdated Show resolved Hide resolved
lua/search.lua Outdated Show resolved Hide resolved
@iDvel
Copy link
Owner Author

iDvel commented Jan 28, 2024

换回了 table_translator 的方式。
reverse_lookup_translator 的方式在反查的时候,有些字出现和消失的时机有点问题:

longlon	龖 𱍂 龘
longlong	龖 𱍂
longlongl	(啥也没有)
longlonglo	(啥也没有)
longlonglon	(啥也没有)
longlonglong	龘

除非开启 enable_completion,但 Rime 默认补全提示只会按照原始编码,即带单引号的方式显示,comment 里剩余编码的个数对不上。

rime_ice.schema.yaml Show resolved Hide resolved
dictionary: radical_pinyin
prefix: "uU" # 反查前缀(反查时前缀会消失影响打英文所以设定为两个字母,或可改成一个非字母符号),与 recognizer/patterns/radical_lookup 匹配
tips: "[拆字]"
enable_user_dict: false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里最好加

enable_sentence: false

不然反查时会出现词组

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有词组不是更好吗,可以直接 uUgongfubuhao → 「巭孬」,这个对双拼有影响吗,如果没影响就不加了。

@iDvel
Copy link
Owner Author

iDvel commented Jan 28, 2024

@mirtlecn 你那里能正常同步吗,我一同步就报错:

E20240128 20:17:54.226804 23411795 level_db.cc:291] Error opening db 'radical_pinyin' read-only.
E20240128 20:17:54.226857 23411795 user_dict_manager.cc:214] error backing up user dict 'radical_pinyin'.
E20240128 20:17:54.530254 23411795 user_dict_manager.cc:230] failed synchronizing 1/2 user dicts.

@iDvel
Copy link
Owner Author

iDvel commented Jan 28, 2024

不知道什么原因,必须部署一次后再同步才行。

换到 script_translator 后,和 reverse_lookup_translator 有同样的问题:

longlon		龖 𱍂 龘
longlong	龖 𱍂
longlongl	(啥也没有)
longlonglo	(啥也没有)
longlonglon	(啥也没有)
longlonglong	龘

尤其对于叠字来说还是希望在输入 longlong 的时候,同时显示 2~4 条龙(龖 龘 𪚥),又换回了 table_translator。

@iDvel iDvel merged commit 8083830 into main Jan 29, 2024
@iDvel iDvel deleted the feat-radical branch January 29, 2024 10:53
iDvel added a commit that referenced this pull request Jan 29, 2024
BREAKING CHANGE: 部件拆字方案替换了两分方案

Co-authored-by: Mirtle <mirtle.cn@outlook.com>
iDvel added a commit that referenced this pull request Jan 29, 2024
BREAKING CHANGE: 部件拆字方案替换了两分方案

Co-authored-by: Mirtle <mirtle.cn@outlook.com>
@iDvel
Copy link
Owner Author

iDvel commented Jan 29, 2024

@mirtlecn 好的学会啦。

@Jreen
Copy link

Jreen commented Jan 30, 2024

我有点迷糊,比如说壎,我先随便打任何字母然后`tuxun,结果我这边没有看到有这个字,我不知道问题在那里,rime文件里面有这个壎,请问怎么打才是正确的方法?

@iDvel
Copy link
Owner Author

iDvel commented Jan 30, 2024

我有点迷糊,比如说壎,我先随便打任何字母然后`tuxun,结果我这边没有看到有这个字,我不知道问题在那里,rime文件里面有这个壎,请问怎么打才是正确的方法?

反查是按照 radical 的词库进行反查,radical 词库有这个字,用 uUtuxun 就可以打出来。

辅码是对目前已有候选项的一个筛选。
「壎」并不在 8105 字表,如果你本身用 xun 就打不出「壎」,那么你输入 xun`tuxun 也打不出来。

@Jreen
Copy link

Jreen commented Jan 30, 2024

谢谢老师提醒我了!!!我去开启字表

@iDvel
Copy link
Owner Author

iDvel commented Jan 30, 2024

随便打任何字母然后`tuxun

不是,你好像这里理解错了,不是「打任何字母」。
你打 ni`shui,筛选出来的是所有拼音为 ni 且是三点水的字,
你打 hao`shui,筛选出来的是所有拼音为 hao 且是三点水的字。

有些偏旁和难检字你可能得翻阅 radical.dict.yaml 看看编码例子,注释里有生僻部件的编码。
一般常用的就是 氵shui 钅jin 艹cao 亻ren 月yue 等等,大概能猜出来。

@Anber55
Copy link

Anber55 commented Feb 3, 2024

请问这个部件拆字的词库是不是比liangfen词库小,但是词库应该都是在两分词库之内吧,因为我做了反查来查两分的编码,不知道是否通用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants