exposes InsertUserWord Find

This commit is contained in:
zhoupeng 2018-06-09 16:21:13 +08:00
parent 1e1e585194
commit 111fb007cf
2 changed files with 28 additions and 0 deletions

View File

@ -72,6 +72,25 @@ class DictTrie {
trie_->Find(begin, end, res, max_word_len); 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 { bool IsUserDictSingleChineseWord(const Rune& word) const {
return IsIn(user_dict_single_chinese_word_, word); return IsIn(user_dict_single_chinese_word_, word);
} }

View File

@ -72,6 +72,15 @@ class Jieba {
return dict_trie_.InsertUserWord(word, tag); 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) { void ResetSeparators(const string& s) {
//TODO //TODO
mp_seg_.ResetSeparators(s); mp_seg_.ResetSeparators(s);