diff --git a/src/__xml4nlp/Xml4nlp.cpp b/src/__xml4nlp/Xml4nlp.cpp index 6c3a12a8c..7778314fe 100644 --- a/src/__xml4nlp/Xml4nlp.cpp +++ b/src/__xml4nlp/Xml4nlp.cpp @@ -101,6 +101,7 @@ int XML4NLP::CreateDOMFromString(const string& str) { string strTmp = str; replace_char_by_char(strTmp, '\r', '\n'); + std::cout << strTmp << std::endl; istringstream in(strTmp); // How to use istringstream? string line; int i = 0; diff --git a/test/ltp_test.cpp b/test/ltp_test.cpp index dd453eeb1..23d7abc00 100644 --- a/test/ltp_test.cpp +++ b/test/ltp_test.cpp @@ -29,10 +29,20 @@ int main(int argc, char *argv[]) { exit(1); } - while(in >> sentence){ + while(std::getline(in, sentence)){ + int len = sentence.size(); + while ( sentence[len-1]=='\n' || sentence[len-1]=='\r' ) { + -- len; + } + if (len == 0) { + continue; + } + sentence = sentence.substr(0, len); + cout << "Input sentence is: " << sentence << endl; xml4nlp.CreateDOMFromString(sentence); + if(type == "ws"){ ltp.wordseg(); } else if(type == "pos"){