-
Notifications
You must be signed in to change notification settings - Fork 23
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
Support correction for shuangpin. #90
Conversation
加一个 这样实现可以吗? |
你的实现只实现了需要做的很小的一部分 首先,双拼用的 pinyin map 用默认的即可。你要做的双拼的 correction,不是一个用了全拼 correction 的 pinyin map 再映射,这是不对的,而且只会让 correction 只支持单字母的声母或者韵母组合。 应该在 buildShuangpinTable 的时候,利用 CorrectionProfile 的内容增加对应的条目。 1、你把 PinyinCorrectionProfile 的最原始的 mapping 保存成为一个属性暴露出来可以让别的类读取
|
改 ShuangpinProfile 的 ctor 的话,如果 Chinese addon 里面改了correctionProfile,还得去重新构造 ShuangpinProfile。 你说的第二步改成这样行不行: |
构造这个又不费什么cpu,不用省。 |
其实不是考虑性能,两种实现都是纠错改了才要构建。只是想要和全拼的实现更一致,不用再去改Chinese addon。 |
检测使用的 CorrectionProfile 是否和上次一样,是更加复杂的逻辑,逻辑越复杂就越容易出 bug 这几个 profile 从一开始就设计为 immutable ,所以逻辑本身很简单,有任何需要生成的数据只生成一次。 |
在shuangpinprofile里加一个BuiltinPinyinCorrectionProfile类型的成员,比较这个enum,如果变了根据它就重新buildShuangpinTable。 |
enum 是内置的几个方便的值,简单来说只是一个 shortcut,PinyinCorrectionProfile 本身的定义是可以任意写的 参见这个构造函数。
|
明白了,谢谢 |
写好了,麻烦看一下 @wengxt |
@@ -47,6 +47,7 @@ getProfileMapping(BuiltinPinyinCorrectionProfile profile) { | |||
class PinyinCorrectionProfilePrivate { | |||
public: | |||
PinyinMap pinyinMap_; | |||
std::unordered_map<char, std::vector<char>> correctionMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name member with underscore
src/libime/pinyin/pinyinime.cpp
Outdated
@@ -183,6 +184,12 @@ void PinyinIME::setCorrectionProfile( | |||
FCITX_D(); | |||
if (d->correctionProfile_ != profile) { | |||
d->correctionProfile_ = std::move(profile); | |||
auto sp = shuangpinProfile(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this part to chinese-addons, so you don't need to change here and keep a copy of the original version.
src/libime/pinyin/shuangpinprofile.h
Outdated
private: | ||
void buildShuangpinTable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though the symbol is private, I'd prefer not to change signature.
Can you just don't touch it (you can delete everything in it's implementation), and create a new function as ShuangpinProfilePrivate::buildShuangpinTable?
This is mainly an issue on ABI compatiblity.
testpinyinime_unit.cpp 运行的日志10: Test command: /home/benyip/ghq/github.com/fcitx/libime/build/test/testpinyinime_unit |
测试也修好了,麻烦看一下能合进去了吗 @wengxt |
测试过纠错是能工作的。
但是目前的实现有问题,无脑在
buildShuangpinTable
的时候指定了qwerty的纠错。无奈不熟悉libime,不知道该怎么改了