mirror of https://github.com/kiwix/libkiwix.git
+ improve suggestions search, search also entitled words
This commit is contained in:
parent
987d6f672f
commit
39fa510af5
|
@ -516,6 +516,10 @@ namespace kiwix {
|
|||
myPrefix = kiwix::lcFirst(myPrefix);
|
||||
this->searchSuggestions(myPrefix, suggestionsCount, false);
|
||||
|
||||
/* Try with title words */
|
||||
myPrefix = kiwix::toTitle(myPrefix);
|
||||
this->searchSuggestions(myPrefix, suggestionsCount, false);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
|
|
@ -207,3 +207,21 @@ std::string kiwix::lcFirst (const std::string &word) {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::string kiwix::toTitle (const std::string &word) {
|
||||
if (word.empty())
|
||||
return "";
|
||||
|
||||
std::string result;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
result = word;
|
||||
#else
|
||||
UnicodeString unicodeWord(word.c_str());
|
||||
unicodeWord = unicodeWord.toTitle(0);
|
||||
unicodeWord.toUTF8String(result);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ namespace kiwix {
|
|||
|
||||
std::string ucFirst(const std::string &word);
|
||||
std::string lcFirst(const std::string &word);
|
||||
std::string toTitle(const std::string &word);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue