MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / BuildDeletesWords

Method BuildDeletesWords

Util/src/SymSpell/SymSpell.cpp:263–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263bool SymSpell::BuildDeletesWords(const std::string &key) {
264 //edits/suggestions are created only once, no matter how often word occurs
265 //edits/suggestions are created only as soon as the word occurs in the corpus,
266 //even if the same term existed before in the dictionary as an edit from another word
267 if (key.size() > _maxDictionaryWordLength) {
268 _maxDictionaryWordLength = key.size();
269 }
270 //create deletes
271 auto edits = EditsPrefix(key);
272 for (auto it = edits.begin(); it != edits.end(); ++it) {
273 int deleteHash = GetStringHash(*it);
274 auto deletesFounded = _deletes.find(deleteHash);
275 if (deletesFounded != _deletes.end()) {
276 auto &suggestions = deletesFounded->second;
277 suggestions.emplace_back(key);
278 } else {
279 std::vector<std::string> suggestions = {key};
280
281 _deletes.insert({deleteHash, suggestions});
282 }
283 }
284 return true;
285}
286
287bool SymSpell::BuildAllDeletesWords() {
288 bool ret = true;

Callers

nothing calls this directly

Calls 5

sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
findMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected