forked from HIT-SCIR/ltp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpos.cpp
37 lines (26 loc) · 763 Bytes
/
pos.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <vector>
#include "ltp/postag_dll.h"
int main(int argc, char * argv[]) {
if (argc < 2) {
std::cerr << "pos [model path]" << std::endl;
return -1;
}
void * engine = postagger_create_postagger(argv[1]);
if (!engine) {
return -1;
}
std::vector<std::string> words;
words.push_back("我");
words.push_back("是");
words.push_back("中国人");
std::vector<std::string> tags;
postagger_postag(engine, words, tags);
for (int i = 0; i < tags.size(); ++ i) {
std::cout << words[i] << "/" << tags[i];
if (i == tags.size() - 1) std::cout << std::endl;
else std::cout << " ";
}
postagger_release_postagger(engine);
return 0;
}