Use heuristic weighted length algorithm to calculate the query term length.
ClosedPublic

Authored by xuetianweng on Nov 12 2017, 11:02 AM.

Details

Summary

Composing CJK character requires a lot more key comparing to latin
characters. The raw length check does not make much sense for query string
in CJK characters. Here we use a simple algorithm to query the character
script property in unicode. If they are belong to CJK, use length 2 instead
of 1 for the character.

Test Plan

Search "系" (normally requires three key press "x + i + 1" under pinyin) under
zh_CN in krunner and get some result instead of nothing.

Diff Detail

Repository
R120 Plasma Workspace
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
xuetianweng created this revision.Nov 12 2017, 11:02 AM
Restricted Application added a project: Plasma. · View Herald TranscriptNov 12 2017, 11:02 AM

Revert the accident checking length change. Also make weightedLength linkage local.

ihipop added a subscriber: ihipop.Nov 12 2017, 1:06 PM
cfeck added a subscriber: cfeck.Nov 12 2017, 2:36 PM
cfeck added inline comments.
runners/services/servicerunner.cpp
56

Since there is no 'else', the length is increased by 3 for Han characters. Is this intended?

forget to use else..

xuetianweng marked an inline comment as done.Nov 12 2017, 5:47 PM
xuetianweng added inline comments.
runners/services/servicerunner.cpp
56

Yeah you're right.. I intended to use else here.

hein added a comment.Nov 13 2017, 12:48 PM

I've found this problem in many KDE UIs, and I'd like to have a generic solution. How do you feel about adding something like a logicalStringLength() to KCoreAddons or KCodecs? Then we can use it in KRunner, KMail, Amarok, ...

xuetianweng marked an inline comment as done.

Use the new kcoreaddons function to cal the length.

hein accepted this revision.Nov 13 2017, 7:38 PM
This revision is now accepted and ready to land.Nov 13 2017, 7:38 PM
This revision was automatically updated to reflect the committed changes.