mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-27 06:10:52 -04:00
+ move improved suggestion system (check also variations of the prefix) to reader.cpp
This commit is contained in:
parent
7cf557b44d
commit
149c840d99
@ -224,7 +224,7 @@ static int accessHandlerCallback(void *cls,
|
|||||||
|
|
||||||
/* Get the suggestions */
|
/* Get the suggestions */
|
||||||
content = "[";
|
content = "[";
|
||||||
reader->searchSuggestions(term, maxSuggestionCount);
|
reader->searchSuggestionsSmart(term, maxSuggestionCount);
|
||||||
while (reader->getNextSuggestion(suggestion)) {
|
while (reader->getNextSuggestion(suggestion)) {
|
||||||
kiwix::stringReplacement(suggestion, "\"", "\\\"");
|
kiwix::stringReplacement(suggestion, "\"", "\\\"");
|
||||||
content += (content == "[" ? "" : ",");
|
content += (content == "[" ? "" : ",");
|
||||||
@ -232,30 +232,6 @@ static int accessHandlerCallback(void *cls,
|
|||||||
suggestionCount++;
|
suggestionCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to get further suggestions with ucFirst(pattern) if maxSuggestionCount is not reached */
|
|
||||||
if (suggestionCount < 10) {
|
|
||||||
term = kiwix::ucFirst(term);
|
|
||||||
reader->searchSuggestions(term, maxSuggestionCount);
|
|
||||||
while (reader->getNextSuggestion(suggestion) && suggestionCount < 10) {
|
|
||||||
kiwix::stringReplacement(suggestion, "\"", "\\\"");
|
|
||||||
content += (content == "[" ? "" : ",");
|
|
||||||
content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}";
|
|
||||||
suggestionCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try to get further suggestions with lcFirst(pattern) if maxSuggestionCount is not reached */
|
|
||||||
if (suggestionCount < 10) {
|
|
||||||
term = kiwix::lcFirst(term);
|
|
||||||
reader->searchSuggestions(term, maxSuggestionCount);
|
|
||||||
while (reader->getNextSuggestion(suggestion) && suggestionCount < 10) {
|
|
||||||
kiwix::stringReplacement(suggestion, "\"", "\\\"");
|
|
||||||
content += (content == "[" ? "" : ",");
|
|
||||||
content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}";
|
|
||||||
suggestionCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
content += (suggestionCount == 0 ? "" : ",");
|
content += (suggestionCount == 0 ? "" : ",");
|
||||||
content += "{\"value\":\"" + std::string(term) + " \", \"label\":\"containing '" + std::string(term) + "'...\"}]";
|
content += "{\"value\":\"" + std::string(term) + " \", \"label\":\"containing '" + std::string(term) + "'...\"}]";
|
||||||
mimeType = "text/x-json; charset=utf-8";
|
mimeType = "text/x-json; charset=utf-8";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user