user dict support user weight and user tag

This commit is contained in:
bigelephant29 2016-07-21 10:38:46 +08:00
parent b82acaf71e
commit 2e1b6e0443

View File

@ -4,6 +4,7 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <map> #include <map>
#include <string>
#include <cstring> #include <cstring>
#include <stdint.h> #include <stdint.h>
#include <cmath> #include <cmath>
@ -108,10 +109,17 @@ class DictTrie {
buf.clear(); buf.clear();
Split(line, buf, " "); Split(line, buf, " ");
DictUnit node_info; DictUnit node_info;
MakeNodeInfo(node_info, if(buf.size() == 1){
buf[0], MakeNodeInfo(node_info,
user_word_default_weight_, buf[0],
(buf.size() == 3 ? buf[2] : UNKNOWN_TAG)); user_word_default_weight_,
UNKNOWN_TAG);
} else {
MakeNodeInfo(node_info,
buf[0],
(buf.size() == 2 ? std::stoi(buf[1], nullptr) : user_word_default_weight_),
(buf.size() == 3 ? buf[2] : buf[1]));
}
static_node_infos_.push_back(node_info); static_node_infos_.push_back(node_info);
if (node_info.word.size() == 1) { if (node_info.word.size() == 1) {
user_dict_single_chinese_word_.insert(node_info.word[0]); user_dict_single_chinese_word_.insert(node_info.word[0]);