Skip to content

Commit

Permalink
remove space erasing strategy on set sent. to xml, read in 1 line on …
Browse files Browse the repository at this point in the history
…ltp_test
  • Loading branch information
Oneplus committed Jul 25, 2013
1 parent 6cef1cc commit f2c14b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/__xml4nlp/Xml4nlp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ 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;
while (getline(in, strTmp)) {
clean_str(strTmp);
remove_space_gbk(strTmp);
// remove_space_gbk(strTmp);

if (strTmp.empty()) {
continue;
Expand Down
12 changes: 11 additions & 1 deletion test/ltp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"){
Expand Down

0 comments on commit f2c14b5

Please sign in to comment.