+ improve suggestions search, search also entitled words

This commit is contained in:
kelson42 2013-11-10 17:54:11 +01:00
parent 987d6f672f
commit 39fa510af5
3 changed files with 23 additions and 0 deletions

View File

@ -516,6 +516,10 @@ namespace kiwix {
myPrefix = kiwix::lcFirst(myPrefix); myPrefix = kiwix::lcFirst(myPrefix);
this->searchSuggestions(myPrefix, suggestionsCount, false); this->searchSuggestions(myPrefix, suggestionsCount, false);
/* Try with title words */
myPrefix = kiwix::toTitle(myPrefix);
this->searchSuggestions(myPrefix, suggestionsCount, false);
return retVal; return retVal;
} }

View File

@ -207,3 +207,21 @@ std::string kiwix::lcFirst (const std::string &word) {
return result; 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;
}

View File

@ -58,6 +58,7 @@ namespace kiwix {
std::string ucFirst(const std::string &word); std::string ucFirst(const std::string &word);
std::string lcFirst(const std::string &word); std::string lcFirst(const std::string &word);
std::string toTitle(const std::string &word);
} }
#endif #endif