forked from HIT-SCIR/ltp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathltp_test2.cpp
55 lines (42 loc) · 1.03 KB
/
ltp_test2.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Defines the entry point for the console application.
//
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include "Xml4nlp.h"
#include "Ltp.h"
using namespace std;
XML4NLP xml4nlp;
static LTP ltp;
int main(int argc, char *argv[])
{
if (argc != 4)
{
cerr << "Usage: ./ltp_test <type> <test_file> <result_file>" << endl;
exit(1);
}
string type(argv[1]);
string in_file(argv[2]);
string res_file(argv[3]);
xml4nlp.CreateDOMFromFile(in_file.c_str());
if (type == "ws") {
ltp.crfWordSeg(xml4nlp);
} else if(type == "pos"){
ltp.postag(xml4nlp);
} else if(type == "ner"){
ltp.ner(xml4nlp);
} else if(type == "dp"){
ltp.gparser(xml4nlp);
} else if(type == "srl"){
ltp.srl(xml4nlp);
} else {
ltp.srl(xml4nlp);
}
string result;
xml4nlp.SaveDOM(result);
ofstream out(res_file.c_str());
out << result << endl;
cerr << "Results saved to " << res_file << endl;
xml4nlp.ClearDOM();
return 0;
}