From 8f5331424a943adaa1b7f8747f0a37add12c3d0f Mon Sep 17 00:00:00 2001 From: jiangfeng1124 Date: Tue, 2 Apr 2013 15:01:37 +0800 Subject: [PATCH] add a test program to test/ --- test/ltp_test2.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 test/ltp_test2.cpp diff --git a/test/ltp_test2.cpp b/test/ltp_test2.cpp new file mode 100644 index 000000000..213674b9b --- /dev/null +++ b/test/ltp_test2.cpp @@ -0,0 +1,53 @@ +// Defines the entry point for the console application. +// + +#include +#include +#include + +#include "Xml4nlp.h" +#include "Ltp.h" + +using namespace std; + +static XML4NLP xml4nlp; +static LTP ltp(xml4nlp); + +int main(int argc, char *argv[]) +{ + if (argc != 3) + { + cerr << "Usage: ./ltp_test " << endl; + exit(1); + } + + string type(argv[1]); + string in(argv[2]); + + xml4nlp.CreateDOMFromFile(in.c_str()); + + if (type == "ws") { + ltp.crfWordSeg(); + } else if(type == "pos"){ + ltp.postag(); + } else if(type == "ner"){ + ltp.ner(); + } else if(type == "dp"){ + ltp.gparser(); + } else if(type == "srl"){ + ltp.srl(); + } else { + ltp.srl(); + } + + string result; + xml4nlp.SaveDOM(result); + ofstream out((in + ".xml").c_str()); + out << result << endl; + cerr << "Results saved to " << (in + ".xml") << endl; + + xml4nlp.ClearDOM(); + + return 0; +} +