src/DocSim/doc_sim.cpp
// Convert a document to a string so that we can extract its tokens
// Assumes a set of "fields" to be processed. These are assumed to be non-overlapping;
//   the contents of each will be added. For instance, for ICEWS, the only field is "sentence".
//   For another task, the fields might be "HEADLINE" and "TEXT".

Convert a document to a string so that we can extract its tokens
Assumes a set of "fields" to be processed. These are assumed to be non-overlapping;
the contents of each will be added. For instance, for ICEWS, the only field is "sentence".
For another task, the fields might be "HEADLINE" and "TEXT".
Convert a document to a string so that we can extract its tokens Assumes a set of " fields " to be processed . These are assumed to be non - overlapping ; the contents of each will be added . For instance for ICEWS the only field is " sentence " . For another task the fields might be " HEADLINE " and " TEXT " .
std::string xml_to_string( boost::filesystem::path path, std::vector<std::string>& field_values ){
	DOMDocument* doc = XMLUtil::loadXercesDOMFromFilename(path.string().c_str());
	std::stringstream text_str;
	BOOST_FOREACH(std::string field_value, field_values) {
		SerifXML::xstring x_field_value = SerifXML::transcodeToXString(field_value.c_str());
		DOMNodeList *fields = doc->getElementsByTagName(x_field_value.c_str());		
		for (size_t i = 0; i < fields->getLength(); i++) {
			DOMElement *field = (DOMElement *)fields->item(i);
			std::string scontent = SerifXML::transcodeToStdString(field->getTextContent());
			text_str << scontent;			
		}
		text_str << "\n";
	}
	return text_str.str();
}
std :: string xml_to_string ( boost :: filesystem :: path path , std :: vector < std :: string > & field_values ) { DOMDocument * doc = XMLUtil :: loadXercesDOMFromFilename ( path . string ( ) . c_str ( ) ) ; std :: stringstream text_str ; BOOST_FOREACH ( std :: string field_value , field_values ) { SerifXML :: xstring x_field_value = SerifXML :: transcodeToXString ( field_value . c_str ( ) ) ; DOMNodeList * fields = doc -> getElementsByTagName ( x_field_value . c_str ( ) ) ; for ( size_t i = 0 ; i < fields -> getLength ( ) ; i ++ ) { DOMElement * field = ( DOMElement * ) fields -> item ( i ) ; std :: string scontent = SerifXML :: transcodeToStdString ( field -> getTextContent ( ) ) ; text_str << scontent ; } text_str << " \n " ; } return text_str . str ( ) ; }
Convert a document to a string so that we can extract its tokens
Assumes a set of "fields" to be processed.
Convert a document to a string so that we can extract its tokens Assumes a set of " fields " to be processed .