forked from HIT-SCIR/ltp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
par.cpp
37 lines (27 loc) · 866 Bytes
/
par.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/parser_dll.h"
int main(int argc, char * argv[]) {
if (argc < 2) {
return -1;
}
void * engine = parser_create_parser(argv[1]);
if (!engine) {
return -1;
}
std::vector<std::string> words;
std::vector<std::string> postags;
words.push_back("一把手"); postags.push_back("n");
words.push_back("亲自"); postags.push_back("d");
words.push_back("过问"); postags.push_back("v");
words.push_back("。"); postags.push_back("wp");
std::vector<int> heads;
std::vector<std::string> deprels;
parser_parse(engine, words, postags, heads, deprels);
for (int i = 0; i < heads.size(); ++ i) {
std::cout << words[i] << "\t" << postags[i] << "\t"
<< heads[i] << "\t" << deprels[i] << std::endl;
}
parser_release_parser(engine);
return 0;
}