From fb39c7deaab356307868dc5199083e41b18f0f4a Mon Sep 17 00:00:00 2001 From: Oneplus Date: Sun, 24 May 2015 08:48:11 +0800 Subject: [PATCH] Fix dos2unix bug in xml4nlp --- src/xml4nlp/Xml4nlp.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/xml4nlp/Xml4nlp.cpp b/src/xml4nlp/Xml4nlp.cpp index cbacbc38a..866faf3c0 100644 --- a/src/xml4nlp/Xml4nlp.cpp +++ b/src/xml4nlp/Xml4nlp.cpp @@ -7,10 +7,10 @@ * In this software, a open source XML parser TinyXML is used * We Thank to the author of it -- Lee Thomason */ - #include "Xml4nlp.h" #include #include "utils/strutils.hpp" +#include "utils/logging.hpp" using ltp::strutils::trim; @@ -98,8 +98,11 @@ int XML4NLP::CreateDOMFromString(const string & str) { ClearDOM(); if (0 != BuildDOMFrame()) return -1; - string strTmp; - istringstream in(str); // How to use istringstream? + string strTmp = str; + for (size_t i = 0; i < strTmp.size(); ++ i) { + if (strTmp[i] == '\r') { strTmp[i] = '\n'; } + } + istringstream in(strTmp); // How to use istringstream? int i = 0; while (getline(in, strTmp)) { // clean_str(strTmp);