| 57 | } |
| 58 | |
| 59 | bool SymSpell::CreateDictionaryEntry(const std::string &key, int count) { |
| 60 | if (count <= 0) { |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | auto wordsFounded = _words.find(key); |
| 65 | if (wordsFounded != _words.end()) { |
| 66 | int countPrevious = wordsFounded->second; |
| 67 | count = (std::numeric_limits<int>::max() - countPrevious > count) |
| 68 | ? (countPrevious + count) |
| 69 | : std::numeric_limits<int>::max(); |
| 70 | wordsFounded->second = count; |
| 71 | return false; |
| 72 | } else { |
| 73 | _words.insert({key, count}); |
| 74 | } |
| 75 | |
| 76 | if (_strategy == Strategy::LazyLoaded) { |
| 77 | return true; |
| 78 | } |
| 79 | |
| 80 | return BuildDeletesWords(key); |
| 81 | } |
| 82 | |
| 83 | bool SymSpell::IsCorrectWord(const std::string &word) const { |
| 84 | return (word.size() <= static_cast<std::size_t>(_maxDictionaryEditDistance)) || (_words.count(word) == 1); |