void WeightingFunctionInstanceConstant::addNumericParameter( const std::string& name, const NumericVariant& value)
{
	if (strus::caseInsensitiveEquals( name, "precalc"))
	{
		m_precalc = value.toint();
	}
	else if (strus::caseInsensitiveEquals( name, "match"))
	{
		m_errorhnd->report( ErrorCodeInvalidArgument, _TXT("parameter '%s' for weighting scheme '%s' expected to be defined as feature and not as string or numeric value"), name.c_str(), THIS_METHOD_NAME);
	}
	else if (strus::caseInsensitiveEquals( name, "weight"))
	{
		m_weight = (double)value;
	}
	else
	{
		m_errorhnd->report( ErrorCodeUnknownIdentifier, _TXT("unknown '%s' weighting function parameter '%s'"), THIS_METHOD_NAME, name.c_str());
	}
}
Beispiel #2
0
void SummarizerFunctionInstanceListMatches::addNumericParameter( const std::string& name, const NumericVariant& val)
{
	if (utils::caseInsensitiveEquals( name, "match"))
	{
		m_errorhnd->report( _TXT("parameter '%s' for summarizer '%s' expected to be defined as feature and not as numeric value"), name.c_str(), "matchpos");
	}
	else if (utils::caseInsensitiveEquals( name, "name"))
	{
		m_errorhnd->report( _TXT("parameter '%s' for summarizer '%s' expected to be defined as string and not as numeric value"), name.c_str(), "matchpos");
	}
	else if (utils::caseInsensitiveEquals( name, "N"))
	{
		m_maxNofMatches = val.touint();
	}
	else
	{
		m_errorhnd->report( _TXT("unknown '%s' summarization function parameter '%s'"), "matchpos", name.c_str());
	}
}
void SummarizerFunctionInstanceForwardIndex::addNumericParameter( const std::string& name, const NumericVariant& val)
{
	if (strus::caseInsensitiveEquals( name, "name"))
	{
		m_errorhnd->report( ErrorCodeInvalidArgument, _TXT("parameter '%s' for summarizer '%s' expected to be defined as string and not as numeric value"), name.c_str(), THIS_METHOD_NAME);
	}
	else if (strus::caseInsensitiveEquals( name, "type"))
	{
		m_errorhnd->report( ErrorCodeInvalidArgument, _TXT("parameter '%s' for summarizer '%s' expected to be defined as string and not as numeric value"), name.c_str(), THIS_METHOD_NAME);
	}
	else if (strus::caseInsensitiveEquals( name, "N"))
	{
		m_maxNofMatches = std::min(
			val.touint(),
			(NumericVariant::UIntType)std::numeric_limits<unsigned int>::max());
	}
	else
	{
		m_errorhnd->report( ErrorCodeUnknownIdentifier, _TXT("unknown '%s' summarization function parameter '%s'"), THIS_METHOD_NAME, name.c_str());
	}
}
static NumericVariant parameterValue( const std::string& name, const std::string& value)
{
	NumericVariant rt;
	if (!rt.initFromString(value.c_str())) throw strus::runtime_error(_TXT("numeric value expected as parameter '%s' (%s)"), name.c_str(), value.c_str());
	return rt;
}