MCPcopy Create free account
hub / github.com/Predelnik/DSpellCheck / get_suggestions

Method get_suggestions

src/spellers/HunspellInterface.cpp:433–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431}
432
433std::vector<std::wstring> HunspellInterface::get_suggestions(const wchar_t *word) const {
434 std::vector<std::string> list;
435 m_last_selected_speller = nullptr;
436
437 switch (m_speller_mode) {
438 case SpellerMode::SingleLanguage: {
439 m_last_selected_speller = m_singular_speller;
440 if (!m_singular_speller->is_loaded())
441 return {};
442 list = m_singular_speller->hunspell->suggest(m_singular_speller->to_dictionary_encoding(word));
443 }
444 break;
445 case SpellerMode::MultipleLanguages: {
446 for (auto speller : m_spellers) {
447 if (!speller->is_loaded())
448 continue;
449 auto cur_list = speller->hunspell->suggest(speller->to_dictionary_encoding(word));
450 if (cur_list.size() > list.size()) {
451 list = std::move(cur_list);
452 m_last_selected_speller = speller;
453 }
454 }
455 }
456 break;
457 }
458
459 if (!m_last_selected_speller)
460 return {};
461
462 std::vector<std::wstring> sugg_list(list.size());
463 std::transform(list.begin(), list.end(), sugg_list.begin(), [this](const std::string &s) { return m_last_selected_speller->from_dictionary_encoding(s); });
464 return sugg_list;
465}
466
467void HunspellInterface::set_directory(const wchar_t *dir) {
468 if (dir == nullptr || *dir == L'\0')

Callers

nothing calls this directly

Calls 7

is_loadedMethod · 0.80
suggestMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected