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

Feature request: Option for table engine to allow matching substrings. #162

Open
zelch opened this issue Mar 19, 2024 · 7 comments
Open

Comments

@zelch
Copy link

zelch commented Mar 19, 2024

Right now, the only two options are prefix matching and exact matching.

But it would be quite handy for a table that I'm working on (emoticons) if we could optionally match anywhere in the key.

Looking at the code, this doesn't look entirely trivial, but if there is interest I'd be willing to take a crack at trying to implement it.

@wengxt
Copy link
Member

wengxt commented Mar 20, 2024

The table engine is not designed to be used with fuzzy segmentation. I'm not sure what you try to do with this, but what about you just put multiple key for the same value?

@zelch
Copy link
Author

zelch commented Mar 20, 2024

Is there another engine that would be better suited for tables with this use case?

Don't get me wrong, I could write a new one I suppose, but I'm still wrapping my head around the IM API.

@wengxt
Copy link
Member

wengxt commented Mar 20, 2024

@zelch you need to explain what you exactly want to do.

@zelch
Copy link
Author

zelch commented Mar 20, 2024

@wengxt My apologies.

The end goal is a decent interface for entering emoticons.

As an example, you have 💜, which has the name 'purple_heart'.

This really should come up for both starting to enter 'purple', and starting to enter 'heart', or even something silly like 'ple_hea'.

While some options exist, currently there doesn't seem to be anything which is configurable to be specific to emoticons (as opposed to general unicode for example), and which uses the fcitx5 user interface.

Perhaps the closest is im-emoji-picker, but the lack of properly using the fcitx5 UI is... Painful on wayland.

On the other hand, this is a case where the list of emoticon name/character sequences is just a table. And not even all that huge of a table.

@wengxt
Copy link
Member

wengxt commented Mar 20, 2024

@zelch I suggest you check quickphrase, which can be used globally everywhere with meta + ` by default.

Theres builtin configuration that has emoji already, with the emoji alpha code.
https://github.com/fcitx/fcitx5/blob/master/src/modules/quickphrase/quickphrase.d/emoji-eac.mb

While this is also prefix matching, you can extend with either lua or c++ to do whatever you want.

@zelch
Copy link
Author

zelch commented Mar 20, 2024

@wengxt I don't suppose you have an examples of extending quickphrase?

@wengxt
Copy link
Member

wengxt commented Mar 21, 2024

Example of extending quickphrase in C++

https://github.com/fcitx/fcitx5/blob/307d40802469ce8ef4d42ae85467907b575e0fac/src/modules/quickphrase/quickphrase_public.h#L48

https://github.com/fcitx/fcitx5-lua/blob/4c6b48631af963a63f81e6b03c9d73320c538ea0/src/addonloader/luaaddonstate.cpp#L380

See https://codedocs.xyz/fcitx/fcitx5/classfcitx_1_1AddonInstance.html on how to call the exported addon function.

Example of extending quickphrase in lua
https://github.com/fcitx/fcitx5-lua/blob/4c6b48631af963a63f81e6b03c9d73320c538ea0/src/imeapi/imeapi.lua#L132

Also if you use "keyboard" engine, you may already use the keyboard engine's language to query emoji

图片

图片

This is query using fcitx's built-in emoji db https://github.com/fcitx/fcitx5/blob/307d40802469ce8ef4d42ae85467907b575e0fac/src/modules/emoji/emoji_public.h#L24 which is derived from unicode cldr.

While API is Emoji::prefix, it's prefix on keyword. So apple should match any word that is a part of the keyword.

Though one thing to note is that keyboard engine tries to filter out the based on input and result length. If you have a better idea on this you may also improve the code here instead?
https://github.com/fcitx/fcitx5/blob/307d40802469ce8ef4d42ae85467907b575e0fac/src/im/keyboard/keyboard.cpp#L621

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

No branches or pull requests

2 participants