diff --git a/include/cppjieba/DictTrie.hpp b/include/cppjieba/DictTrie.hpp index 25aa5cf..33fa5c6 100644 --- a/include/cppjieba/DictTrie.hpp +++ b/include/cppjieba/DictTrie.hpp @@ -72,6 +72,25 @@ class DictTrie { trie_->Find(begin, end, res, max_word_len); } + bool Find(const string& word) + { + const DictUnit *tmp = NULL; + RuneStrArray runes; + if (!DecodeRunesInString(word, runes)) + { + XLOG(ERROR) << "Decode failed."; + } + tmp = Find(runes.begin(), runes.end()); + if (tmp == NULL) + { + return false; + } + else + { + return true; + } + } + bool IsUserDictSingleChineseWord(const Rune& word) const { return IsIn(user_dict_single_chinese_word_, word); } diff --git a/include/cppjieba/Jieba.hpp b/include/cppjieba/Jieba.hpp index a8f6751..abd321d 100644 --- a/include/cppjieba/Jieba.hpp +++ b/include/cppjieba/Jieba.hpp @@ -72,6 +72,15 @@ class Jieba { return dict_trie_.InsertUserWord(word, tag); } + bool InsertUserWord(const string& word,int freq, const string& tag = UNKNOWN_TAG) { + return dict_trie_.InsertUserWord(word,freq, tag); + } + + bool Find(const string& word) + { + return dict_trie_.Find(word); + } + void ResetSeparators(const string& s) { //TODO mp_seg_.ResetSeparators(s);