src/PredFinder/common/ElfMultiDoc.cpp
/** 
 * Reads either (a) three-column lines (type, name, URI) such as the following: 
 *		nfl:NFLTeam	Arizona Cardinals	nfl:ArizonaCardinals
 *		nfl:NFLTeam	Cardinals	nfl:ArizonaCardinals
 * in which case the docid is assumed to be the special string L"ALL",
 * or (b) four-column lines, where the first column is an actual docid.
 * For each line, produces a mapping from a (docid, type) pair to a triplet of (name, URI) pairs,
 * used to map from original, uppercased, and lowercased versions of the name to a URI. (If, e.g.,
 * original and lowercased versions of the name are identical, only two mappings will be produced.)
 * Example of mappings produced from the lines above:
 * ("ALL", nfl:NFLTeam) -> { ("Arizona Cardinals", "nfl:ArizonaCardinals",
 *                           ("arizona cardinals", "nfl:ArizonaCardinals",
 *							  "ARIZONA CARDINALS", "nfl:ArizonaCardinals")}
 * ("ALL", nfl:NFLTeam) -> { ("Cardinals", "nfl:ArizonaCardinals",
 *                           ("cardinals", "nfl:ArizonaCardinals",
 *							  "CARDINALS", "nfl:ArizonaCardinals")}
 * 
 * @param path Path to an arg map (which may contain a bogus line or have substantive content).
 **/


@param path Path to an arg map (which may contain a bogus line or have substantive content).
@param path Path to an arg map ( which may contain a bogus line or have substantive content ) .
void ElfMultiDoc::init_type_w_or_wo_docid_to_srm_map(const std::string & path) {
	if (path == "")	{
		std::ostringstream out;
		out << "Argument map was not specified but is mandatory";
		throw std::runtime_error(out.str());
	}
	else if (!boost::filesystem::exists(path)) {
		std::ostringstream out;
		out << "Argument map (" << path << ") doesn't exist";
		throw std::runtime_error(out.str());
	}
	SessionLogger::info("read_argm_0") << "Reading argument map " << path << "..." << std::endl;
	std::wstring line;
	std::wifstream arg_map_wifstream(path.c_str());
	int lines_inserted(0);
	while (arg_map_wifstream.is_open() && getline(arg_map_wifstream, line)) {
		boost::algorithm::trim(line);
		if (!line.empty() && line[0] != L'#') {
			std::vector<std::wstring> line_tokens;
			boost::algorithm::split(line_tokens, line, boost::algorithm::is_from_range(L'\t', L'\t'));
			if (line_tokens.size() == 4) {
				process_srm_map_line_w_docid(line_tokens);
				++lines_inserted;
			} else if (line_tokens.size() == 3) {
				process_srm_map_line_wo_docid(line_tokens);
				++lines_inserted;
			} else {
				SessionLogger::info("LEARNIT") << "Bad argument map line: '" << line << "'" << std::endl;
				continue;
			}
		}
	}
	if (lines_inserted == 0) {
		std::ostringstream out;
		out << "Argument map (" << path << ") contains no valid lines";
		throw std::runtime_error(out.str());
	}
}
void ElfMultiDoc :: init_type_w_or_wo_docid_to_srm_map ( const std :: string & path ) { if ( path == " " ) { std :: ostringstream out ; out << " " ; throw std :: runtime_error ( out . str ( ) ) ; } else if ( ! boost :: filesystem :: exists ( path ) ) { std :: ostringstream out ; out << " " << path << " " ; throw std :: runtime_error ( out . str ( ) ) ; } SessionLogger :: info ( " " ) << " " << path << " " << std :: endl ; std :: wstring line ; std :: wifstream arg_map_wifstream ( path . c_str ( ) ) ; int lines_inserted ( 0 ) ; while ( arg_map_wifstream . is_open ( ) && getline ( arg_map_wifstream , line ) ) { boost :: algorithm :: trim ( line ) ; if ( ! line . empty ( ) && line [ 0 ] != L' ' ) { std :: vector < std :: wstring > line_tokens ; boost :: algorithm :: split ( line_tokens , line , boost :: algorithm :: is_from_range ( L' \t ' , L' \t ' ) ) ; if ( line_tokens . size ( ) == 4 ) { process_srm_map_line_w_docid ( line_tokens ) ; ++ lines_inserted ; } else if ( line_tokens . size ( ) == 3 ) { process_srm_map_line_wo_docid ( line_tokens ) ; ++ lines_inserted ; } else { SessionLogger :: info ( " " ) << " " << line << " " << std :: endl ; continue ; } } } if ( lines_inserted == 0 ) { std :: ostringstream out ; out << " " << path << " " ; throw std :: runtime_error ( out . str ( ) ) ; } }
Reads either (a) three-column lines (type, name, URI) such as the following:
              nfl:NFLTeam     Arizona Cardinals       nfl:ArizonaCardinals
              nfl:NFLTeam     Cardinals       nfl:ArizonaCardinals
 in which case the docid is assumed to be the special string L"ALL",
 or (b) four-column lines, where the first column is an actual docid.
Reads either ( a ) three - column lines ( type name URI ) such as the following : nfl : NFLTeam Arizona Cardinals nfl : ArizonaCardinals nfl : NFLTeam Cardinals nfl : ArizonaCardinals in which case the docid is assumed to be the special string L " ALL " or ( b ) four - column lines where the first column is an actual docid .
// Read the tab-delimited table row (where initial hash mark comments out a line)
 // Split the line
 // Check whether this list entry specifies by docid or not
