Calibrate the matching rate of CommandFinder 00/283800/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Tue, 25 Oct 2022 06:54:43 +0000 (15:54 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Thu, 3 Nov 2022 05:44:38 +0000 (14:44 +0900)
Change-Id: Ie6040ce791f7ce4583330cc488f0daa1078312b5
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
src/mmimgr/iu/CommandFinder.cpp

index 4f16465..3b2e3b2 100644 (file)
@@ -28,7 +28,7 @@
 using namespace std;
 
 CommandFinder::CommandFinder(std::string &text, int index, bool isIndex, std::list<std::shared_ptr<ClickableItem>> &commands) :
-               __WORD_MATCHING_RATE(0.3), __CHAR_MATCHING_RATE(0.25), __MIN_WORD_SIZE(3), __commands(commands)
+               __WORD_MATCHING_RATE(0.3), __CHAR_MATCHING_RATE(0.35), __MIN_WORD_SIZE(3), __commands(commands)
 {
        _I("[CommandFinder] Initiate command searcher. text(%s) index(%d), isIndex(%d)", text.c_str(), index, isIndex);
 
@@ -165,8 +165,8 @@ ClickableItem* CommandFinder::findCommandByChar()
                        }
 
                        // This is for calculating Levenshtein distance as similarity matric.
-                       const int __MIN_THRESHOLD = word.size() * __CHAR_MATCHING_RATE;
-                       int minScore = __MIN_THRESHOLD + 1;
+                       const int __MIN_THRESHOLD = (int)(word.size() * __CHAR_MATCHING_RATE) + 1;
+                       int minScore = __MIN_THRESHOLD;
                        _D("[CommandFinder] Minimum matching character number (%d)", __MIN_THRESHOLD);
                        for (auto& labelWord : splitLabel) {
                                if (labelWord.size() < __MIN_WORD_SIZE) {
@@ -219,9 +219,8 @@ ClickableItem* CommandFinder::findCommandByChar()
                                delete[] ncost;
                        }
 
-
-                       _D("[CommandFinder] word(%s), labelword(%s), minscore(%d)", word.c_str(), label.c_str(), minScore);
-                       score += (minScore <= __MIN_THRESHOLD ? minScore : word.size());
+                       score += (minScore < __MIN_THRESHOLD ? minScore : word.size());
+                       _D("[CommandFinder] word(%s), labelword(%s), minscore(%d), score(%d)", word.c_str(), label.c_str(), minScore, score);
                }
 
                _D("[CommandFinder] result score(%d), score(%d)", resultScore, score);