29namespace LinguisticProcessing
36ConstraintFunctionFactory<AgreementConstraint>
72 m_categoryForAgreementAccessor(0)
76 m_categoryForAgreementAccessor=
81 m_categoryForAgreementAccessor=
86 m_categoryForAgreementAccessor=
111 MorphoSyntacticData::const_iterator
112 it1=data1->begin(),it1_end=data1->end();
113 for (; it1!=it1_end; it1++)
115 MorphoSyntacticData::const_iterator
116 it2=data2->begin(),it2_end=data2->end();
117 for (; it2!=it2_end; it2++)
119 if (m_categoryForAgreementAccessor->
empty((*it1).properties)
120 || m_categoryForAgreementAccessor->
empty((*it2).properties)
121 || m_categoryForAgreementAccessor->
equal((*it1).properties,
147 m_propertyAccessor(0),
156 auto j(string::npos),k(string::npos);
157 auto i=str.find(
",");
163 if (i==string::npos || j==string::npos)
166 LIMA_EXCEPTION(
"Constraint LinguisticPropertyIs : invalid complement \""
167 << str.c_str() <<
"\": three arguments needed");
170 string propertyString(str,0,i);
171 string valueString(str,i+1,j-i-1);
172 string lang(str,j+1);
176 .getPropertyCodeManager().getPropertyManager(propertyString);
178 m_propertyAccessor=&(manager.getPropertyAccessor());
180 j=valueString.find(
"|");
181 if (j==std::string::npos) j=valueString.size();
182 for (;i<valueString.size();)
185 pair<LinguisticCode,LinguisticProcessing::LinguisticAnalysisStructure::MorphoSyntacticType> value;
186 k=valueString.find(
"#",i);
187 if (k!=string::npos && k<j)
190 value.first=manager.getPropertyValue(valueString.substr(i,k-i));
191 std::string mtype=valueString.substr(k+1,j-k-1);
192 if (mtype ==
"SIMPLE_WORD") { value.second=
SIMPLE_WORD; }
198 else if (mtype ==
"UNKNOWN_WORD") { value.second=
UNKNOWN_WORD; }
208 LIMA_EXCEPTION(
"Constraint LinguisticPropertyIs : invalid morphosyntactic type \""
209 << mtype.c_str() <<
"\" !");
212 value.first=manager.getPropertyValue(valueString.substr(i,j-i));
216 m_values.push_back(value);
218 j=valueString.find(
"|",i);
219 if (j==string::npos) j=valueString.size();
230 MorphoSyntacticData::const_iterator
234 for (; it!=it_end; it++)
236 for (std::vector<pair<LinguisticCode,LinguisticProcessing::LinguisticAnalysisStructure::MorphoSyntacticType> >::const_iterator pItr=m_values.begin();
237 pItr!=m_values.end();
240 if (m_propertyAccessor->
equal((*it).properties,pItr->first) &&
261 auto i=str.find(
",");
264 m_min=atoi(str.c_str());
269 m_min=atoi(
string(str,0,i).c_str());
270 m_max=atoi(
string(str,i+1).c_str());
280 if (token ==
nullptr)
283 LERROR <<
"Null token on vertex " << v;
287 uint64_t length=token->
length();
296 return (length >= m_min && length <= m_max);
304 m_language(language),
311 std::string::size_type i=str.find(
",");
312 if (i==std::string::npos)
314 m_min=atoi(str.c_str());
319 string minString(str,0,i), maxString(str,i+1);
320 if (minString.empty()) {
324 m_min=atoi(minString.c_str());
326 if (maxString.empty()) {
330 m_max=atoi(maxString.c_str());
341 if (token ==
nullptr)
344 LERROR <<
"Null token on vertex " << v;
348 uint64_t numValue(0);
358 for (MorphoSyntacticData::const_iterator it=data->begin(),
359 it_end=data->end(); it!=it_end; it++) {
371 return ( numValue >= m_min);
374 return ( numValue >= m_min && numValue <= m_max);
392 if (token1 ==
nullptr)
395 LERROR <<
"Null token on vertex " << v1;
398 if (token2 ==
nullptr)
401 LERROR <<
"Null token on vertex " << v2;
#define LIMA_EXCEPTION(X)
This macro writes the message X to a previously configured error stream before throwing a LimaExcepti...
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, LinguisticVertexProperties > LinguisticGraph
Property to identify the chains in the graph.
#define AgreementConstraintId
#define LinguisticPropertyIsId
#define GenderAgreementId
#define LengthInIntervalId
#define NumberAgreementId
#define NumericValueInIntervalId
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
Provide function to read write and check a property.
bool equal(const LinguisticCode &l1, const LinguisticCode &l2) const
check property equality for two linguisticCode
bool empty(const LinguisticCode &l) const
Test if the given code has property data.
generic agreement constraint function: complement must contain the element on which the agreement mus...
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
AgreementConstraint(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticCode &code)
CheckIfEmptyPredicate(const Common::PropertyCode::PropertyAccessor &propAcc)
GenderAgreement(MediaId language, const LimaString &complement=LimaString())
LengthInInterval(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v, AnalysisContent &analysis) const override
unary constraint function : the constraint only applies on one vertices in the graph (the graph is al...
LinguisticPropertyIs(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v, AnalysisContent &analysis) const override
unary constraint function : the constraint only applies on one vertices in the graph (the graph is al...
NoSpaceWith(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
NumberAgreement(MediaId language, const LimaString &complement=LimaString())
NumericValueInInterval(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v, AnalysisContent &analysis) const override
unary constraint function : the constraint only applies on one vertices in the graph (the graph is al...
An AnalysisData containing a LinguisticGraph with a language and an id.
const LinguisticGraphVertex & lastVertex(void) const
Returns the last vertex of the graph.
const LinguisticGraph * getGraph(void) const
Returns the underlying graph structure.
const LinguisticGraphVertex & firstVertex(void) const
Returns the first vertex of the graph.
Holds morphosyntactic informations.
NumericType getNumeric() const
holds surface data of a token
uint64_t position() const
const TStatus & status() const
const LimaString & stringForm() const
static const MediaticData & single()
const singleton accessor
std::string limastring2utf8stdstring(const Lima::LimaString &phrase, uint32_t size0)
Convert a wide string to a string , in dest up to size bytes.
LimaString utf8stdstring2limastring(const std::string &src)
ConstraintFunctionFactory< GenderAgreement > GenderAgreementFactory(GenderAgreementId)
ConstraintFunctionFactory< AgreementConstraint > AgreementConstraintFactory(AgreementConstraintId)
ConstraintFunctionFactory< NumericValueInInterval > NumericValueInIntervalFactory(NumericValueInIntervalId)
ConstraintFunctionFactory< NoSpaceWith > NoSpaceWithFactory(NoSpaceWithId)
ConstraintFunctionFactory< LengthInInterval > LengthInIntervalFactory(LengthInIntervalId)
ConstraintFunctionFactory< LinguisticPropertyIs > LinguisticPropertyIsFactory(LinguisticPropertyIsId)
ConstraintFunctionFactory< NumberAgreement > NumberAgreementFactory(NumberAgreementId)
@ CONCATENATED_ALTERNATIVE