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);
}
// 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) {
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);