mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
add Jieba::Tag
This commit is contained in:
parent
c27d89c60d
commit
60ca5093a9
@ -1,5 +1,9 @@
|
|||||||
# CppJieba ChangeLog
|
# CppJieba ChangeLog
|
||||||
|
|
||||||
|
## next version
|
||||||
|
|
||||||
|
1. 在 class Jieba 中新增词性标注的接口函数 Jieba::Tag
|
||||||
|
|
||||||
## v4.1.0
|
## v4.1.0
|
||||||
|
|
||||||
1. QuerySegment切词时加一层判断,当长词满足IsAllAscii(比如英文单词)时,不进行细粒度分词。
|
1. QuerySegment切词时加一层判断,当长词满足IsAllAscii(比如英文单词)时,不进行细粒度分词。
|
||||||
|
@ -295,7 +295,7 @@ Query方法先使用Mix方法切词,对于切出来的较长的词再使用Ful
|
|||||||
|
|
||||||
```
|
```
|
||||||
我是蓝翔技工拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上总经理,出任CEO,迎娶白富美,走上人生巅峰。
|
我是蓝翔技工拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上总经理,出任CEO,迎娶白富美,走上人生巅峰。
|
||||||
["我:r", "是:v", "蓝翔:x", "技工:n", "拖拉机:n", "学院:n", "手扶拖拉机:n", "专业:n", "的:uj", "。:x", "不用:v", "多久:m", ",:x", "我:r", "就:d", "会:v", "升职:v", "加薪:nr", ",:x", "当:t", "上:f", "总经理:n", ",:x", "出任:v", "CEO:eng", ",:x", "迎娶:v", "白富美:x", ",:x", "走上:v", "人生:n", "巅峰:n", "。:x"]
|
["我:r", "是:v", "拖拉机:n", "学院:n", "手扶拖拉机:n", "专业:n", "的:uj", "。:x", "不用:v", "多久:m", ",:x", "我:r", "就:d", "会:v", "升职:v", "加薪:nr", ",:x", "当上:t", "CEO:eng", ",:x", "走上:v", "人生:n", "巅峰:n", "。:x"]
|
||||||
```
|
```
|
||||||
|
|
||||||
详细请看 `test/demo.cpp`.
|
详细请看 `test/demo.cpp`.
|
||||||
|
@ -17,7 +17,8 @@ class Jieba {
|
|||||||
mix_seg_(&dict_trie_, &model_),
|
mix_seg_(&dict_trie_, &model_),
|
||||||
full_seg_(&dict_trie_),
|
full_seg_(&dict_trie_),
|
||||||
query_seg_(&dict_trie_, &model_),
|
query_seg_(&dict_trie_, &model_),
|
||||||
level_seg_(&dict_trie_) {
|
level_seg_(&dict_trie_),
|
||||||
|
pos_tagger_(&dict_trie_, &model_) {
|
||||||
}
|
}
|
||||||
~Jieba() {
|
~Jieba() {
|
||||||
}
|
}
|
||||||
@ -43,6 +44,9 @@ class Jieba {
|
|||||||
void CutSmall(const string& sentence, vector<string>& words, size_t max_word_len) const {
|
void CutSmall(const string& sentence, vector<string>& words, size_t max_word_len) const {
|
||||||
mp_seg_.Cut(sentence, words, max_word_len);
|
mp_seg_.Cut(sentence, words, max_word_len);
|
||||||
}
|
}
|
||||||
|
void Tag(const string& sentence, vector<pair<string, string> >& words) const {
|
||||||
|
pos_tagger_.Tag(sentence, words);
|
||||||
|
}
|
||||||
bool InsertUserWord(const string& word, const string& tag = UNKNOWN_TAG) {
|
bool InsertUserWord(const string& word, const string& tag = UNKNOWN_TAG) {
|
||||||
return dict_trie_.InsertUserWord(word, tag);
|
return dict_trie_.InsertUserWord(word, tag);
|
||||||
}
|
}
|
||||||
@ -69,6 +73,8 @@ class Jieba {
|
|||||||
QuerySegment query_seg_;
|
QuerySegment query_seg_;
|
||||||
LevelSegment level_seg_;
|
LevelSegment level_seg_;
|
||||||
|
|
||||||
|
PosTagger pos_tagger_;
|
||||||
|
|
||||||
}; // class Jieba
|
}; // class Jieba
|
||||||
|
|
||||||
} // namespace Jieba
|
} // namespace Jieba
|
||||||
|
@ -33,11 +33,11 @@ int main(int argc, char** argv) {
|
|||||||
jieba.Cut("男默女泪", words);
|
jieba.Cut("男默女泪", words);
|
||||||
cout << limonp::join(words.begin(), words.end(), "/") << endl;
|
cout << limonp::join(words.begin(), words.end(), "/") << endl;
|
||||||
|
|
||||||
//cout << "[demo] TAGGING" << endl;
|
cout << "[demo] TAGGING" << endl;
|
||||||
//vector<pair<string, string> > tagres;
|
vector<pair<string, string> > tagres;
|
||||||
//jieba.Tag(s, tagres);
|
jieba.Tag(s, tagres);
|
||||||
//cout << s << endl;
|
cout << s << endl;
|
||||||
//cout << tagres << endl;;
|
cout << tagres << endl;;
|
||||||
|
|
||||||
//cout << "[demo] KEYWORD" << endl;
|
//cout << "[demo] KEYWORD" << endl;
|
||||||
//vector<pair<string, double> > keywordres;
|
//vector<pair<string, double> > keywordres;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user