diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-07-30 19:58:34 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-07-30 19:58:34 +0100 |
| commit | 5fc063c520afea4cdc8593eefa690f1ea804f1f4 (patch) | |
| tree | 3890081a9beab05cb7740834455a3267f74ad266 /src/word_db.cc | |
| parent | 4c31449a6505f802fe990014cc9aa095e3fa2f60 (diff) | |
Insert word completion: Use subsequence matching if prefix failed
Diffstat (limited to 'src/word_db.cc')
| -rw-r--r-- | src/word_db.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/word_db.cc b/src/word_db.cc index dc08f102..e3be4245 100644 --- a/src/word_db.cc +++ b/src/word_db.cc @@ -118,6 +118,19 @@ std::vector<String> WordDB::find_prefix(const String& prefix) return res; } +std::vector<String> WordDB::find_subsequence(const String& subsequence) +{ + update_db(); + + std::vector<String> res; + for (auto it = m_words.begin(); it != m_words.end(); ++it) + { + if (subsequence_match(it->first, subsequence)) + res.push_back(it->first); + } + return res; +} + int WordDB::get_word_occurences(const String& word) const { auto it = m_words.find(word); |
