src/PredFinder/elf/ElfIndividual.cpp
/**
 * Strip every character that is not a minus sign or a digit. Used to produce
 * a value string that represents an xsd:int. This is a static class method,
 * originally implemented in ElfRelationArg.
 *
 * @param original_text The original text (e.g., "5,000").
 * @return The text with everything but minus sign and digits removed (e.g., "5000").
 *
 * @author afrankel@bbn.com
 * @date 2010.07.26
 **/
Strip every character that is not a minus sign or a digit. Used to produce
a value string that represents an xsd:int. This is a static class method,
originally implemented in ElfRelationArg.

@param original_text The original text .
@return The text with everything but minus sign and digits removed .


Strip every character that is not a minus sign or a digit . Used to produce a value string that represents an xsd : int . This is a static class method originally implemented in ElfRelationArg . @param original_text The original text . @return The text with everything but minus sign and digits removed .
std::wstring ElfIndividual::get_normalized_int_text(const std::wstring & original_text) {
	if (original_text.empty()) {
		std::stringstream error;
		error << "ElfIndividual::get_normalized_int_text(std::wstring): Empty input text";
		throw std::runtime_error(error.str().c_str());
	}
	std::wstring lowercased_text(original_text);
	std::transform(lowercased_text.begin(), lowercased_text.end(), lowercased_text.begin(), towlower);
	int return_int = ElfIndividual::number_converter->convertNumberWord(lowercased_text);
	if (return_int > 0) {
		return boost::lexical_cast<std::wstring>(return_int);
	} else if (original_text == L"zero" || original_text == L"0") {
		return L"0";
	} else {
		std::stringstream error;
		error << "ElfIndividual::get_normalized_int_text(std::wstring): Not an integer '" << original_text << "'";
		throw std::runtime_error(error.str().c_str());
	}
}
std :: wstring ElfIndividual :: get_normalized_int_text ( const std :: wstring & original_text ) { if ( original_text . empty ( ) ) { std :: stringstream error ; error << " " ; throw std :: runtime_error ( error . str ( ) . c_str ( ) ) ; } std :: wstring lowercased_text ( original_text ) ; std :: transform ( lowercased_text . begin ( ) , lowercased_text . end ( ) , lowercased_text . begin ( ) , towlower ) ; int return_int = ElfIndividual :: number_converter -> convertNumberWord ( lowercased_text ) ; if ( return_int > 0 ) { return boost :: lexical_cast < std :: wstring > ( return_int ) ; } else if ( original_text == L" " || original_text == L" " ) { return L" " ; } else { std :: stringstream error ; error << " " << original_text << " " ; throw std :: runtime_error ( error . str ( ) . c_str ( ) ) ; } }
Strip every character that is not a minus sign or a digit.
Strip every character that is not a minus sign or a digit .
// Check for valid input string
 // Convert presumed number text to lowercase and parse it into an integer
 // Check the returned integer (note that convertNumberWord() returns zero if input is not a number word)
 // Return the cleaned integer as a string
