mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-25 13:19:59 -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,37 +224,13 @@ static int accessHandlerCallback(void *cls,
|
||||
|
||||
/* Get the suggestions */
|
||||
content = "[";
|
||||
reader->searchSuggestions(term, maxSuggestionCount);
|
||||
reader->searchSuggestionsSmart(term, maxSuggestionCount);
|
||||
while (reader->getNextSuggestion(suggestion)) {
|
||||
kiwix::stringReplacement(suggestion, "\"", "\\\"");
|
||||
content += (content == "[" ? "" : ",");
|
||||
content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}";
|
||||
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 += "{\"value\":\"" + std::string(term) + " \", \"label\":\"containing '" + std::string(term) + "'...\"}]";
|
||||
|
Loading…
x
Reference in New Issue
Block a user