src/DocSim/doc_sim.cpp
// Convert a document  to a string so that we can extract its tokens

Convert a document  to a string so that we can extract its tokens
Convert a document to a string so that we can extract its tokens
std::string segments_to_string( boost::filesystem::path path, std::wstring input_field1, std::wstring input_field2 ){
	std::wifstream fin( path.string().c_str() );
	std::stringstream doc_stream; 
	while( fin ){
		WSegment segment;
		try {
			fin >> segment; 
		} catch (std::runtime_error &e) {
			SessionLogger::info("DocSim") << " Skipping segment in " << path.string() << endl;
			SessionLogger::info("DocSim") << e.what();
			continue;
		}
		if( !fin ) break;
		WSegment::const_iterator field_it = segment.find(input_field1);
		if (field_it == segment.end()) {
			field_it = segment.find(input_field2);
		}
		std::wstring wsentence = field_it->second.at(0).value;
		std::string sentence(wsentence.begin(), wsentence.end());
		doc_stream << sentence;
	}
	return doc_stream.str(); 
}
std :: string segments_to_string ( boost :: filesystem :: path path , std :: wstring input_field1 , std :: wstring input_field2 ) { std :: wifstream fin ( path . string ( ) . c_str ( ) ) ; std :: stringstream doc_stream ; while ( fin ) { WSegment segment ; try { fin >> segment ; } catch ( std :: runtime_error & e ) { SessionLogger :: info ( " " ) << " " << path . string ( ) << endl ; SessionLogger :: info ( " " ) << e . what ( ) ; continue ; } if ( ! fin ) break ; WSegment :: const_iterator field_it = segment . find ( input_field1 ) ; if ( field_it == segment . end ( ) ) { field_it = segment . find ( input_field2 ) ; } std :: wstring wsentence = field_it -> second . at ( 0 ) . value ; std :: string sentence ( wsentence . begin ( ) , wsentence . end ( ) ) ; doc_stream << sentence ; } return doc_stream . str ( ) ; }
Convert a document  to a string so that we can extract its tokens
Convert a document to a string so that we can extract its tokens
// Look for our input field
 // Back off to our second input field if we can't find the first
