forked from HIT-SCIR/ltp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
srl.cpp
38 lines (30 loc) · 1.27 KB
/
srl.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
37
#include <iostream>
#include <vector>
#include "ltp/SRL_DLL.h"
int main(int argc, char * argv[]) {
if (argc < 2) {
return -1;
}
SRL_LoadResource(argv[1]);
std::vector<std::string> words;
std::vector<std::string> postags;
std::vector<std::string> nes;
std::vector<std::pair<int,std::string> > parse;
std::vector< std::pair< int, std::vector< std::pair<std::string, std::pair< int, int > > > > > srl;
words.push_back("一把手"); postags.push_back("n"); nes.push_back("O"); parse.push_back(make_pair(2,"SBV"));
words.push_back("亲自"); postags.push_back("d"); nes.push_back("O"); parse.push_back(make_pair(2,"ADV"));
words.push_back("过问"); postags.push_back("v"); nes.push_back("O"); parse.push_back(make_pair(-1,"HED"));
words.push_back("。"); postags.push_back("wp");nes.push_back("O"); parse.push_back(make_pair(2,"WP"));
DoSRL(words,postags,nes,parse,srl);
for(int i = 0;i<srl.size();++i) {
std::cout<<srl[i].first<<":"<<std::endl;
for(int j = 0;j<srl[i].second.size();++j) {
std::cout<<"\ttype = "<<srl[i].second[j].first
<<" beg = "<<srl[i].second[j].second.first
<<" end = "<<srl[i].second[j].second.second
<<std::endl;
}
}
SRL_ReleaseResource();
return 0;
}