27namespace LinguisticProcessing {
44 StringsPoolIndex formId=(*m_stringsPool)[formStr];
48 recognizedExpression.
length());
52 EntityFeatures::const_iterator f=recognizedExpression.
features().
54 if (f!=recognizedExpression.
features().end()) {
55 lemmaString=boost::any_cast<const LimaString&>((*f).getValue());
58 lemmaString=recognizedExpression.
getString();
61 StringsPoolIndex lemma=(*m_stringsPool)[lemmaString];
66 if (recognizedExpression.
getHead() == 0) {
71 Token* firstToken=recognizedExpression.
getToken(recognizedExpression.begin());
98 newData->push_back(lingElt);
99 return make_pair(newToken,newData);
108 std::set<LinguisticCode> compatibleProperties;
110 compatibleProperties);
114 if (compatibleProperties.empty()) {
116 LWARN <<
"head of expression " << (*m_stringsPool)[lemma] <<
" has no compatible properties, use"<< idiomProperty;
117 compatibleProperties.insert(idiomProperty);
126 std::set<LinguisticCode>::const_iterator
127 prop=compatibleProperties.begin(),
128 prop_end=compatibleProperties.end();
129 for (; prop!=prop_end; prop++) {
131 newData->push_back(lingElt);
134 return make_pair(newToken,newData);
140 std::set<LinguisticCode>& newProperties)
const {
143 MorphoSyntacticData::const_iterator
144 it=headData->begin(),
145 it_end=headData->end();
146 for (; it!=it_end; it++) {
147 if (
isCompatible(baseProperty,(*it).properties,newProperty)) {
148 newProperties.insert(newProperty);
151 return (!newProperties.empty());
160 if (!m_macroAccessor->
empty(baseProperty) &&
161 !m_macroAccessor->
equal(property,baseProperty)) {
166 newProperty=baseProperty;
167 const std::map<std::string,Common::PropertyCode::PropertyManager>&
169 for (map<string,Common::PropertyCode::PropertyManager>::const_iterator propIt=managers.begin();
170 propIt!=managers.end();
173 if (acc.
empty(newProperty)) {
188 tokenMap[altVertex]= token;
189 dataMap[altVertex] = data;
210 boost::tie(it_begin,it_end)=in_edges(startVertex,graph);
216 boost::tie(newEdge, ok) = add_edge(previousVertex, alternativeFirstVertex, graph);
240 boost::tie(it_begin,it_end)=out_edges(endVertex,graph);
246 boost::tie(newEdge, ok) = add_edge(alternativeLastVertex, nextVertex, graph);
257m_propertyCodeManager(0)
264 if (m_propertyCodeManager==0) {
266 LIMA_EXCEPTION(
"cannot acces property code manager for language " << (
int) language );
268 if (m_macroAccessor==0) {
270 LIMA_EXCEPTION(
"cannot initialize MACRO property accessor for language " << (
int) language );
283 auto recoData = std::dynamic_pointer_cast<RecognizerData>(analysis.
getData(
"RecognizerData"));
284 auto anagraph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
"AnalysisGraph"));
291 if (recoData->matchOnRemovedVertices(result)) {
294 LWARN <<
"recognized entity ignored: "
296 <<
": overlapping with a previous one";
301 pair<Token*,MorphoSyntacticData*> newToken=
303 if (newToken.second->empty()) {
305 LERROR <<
"CreateAlternative::operator(): Got empty morphosyntactic data. Abort.";
306 delete newToken.first;
307 delete newToken.second;
320 alternativeVertex,*graph);
322 result.back().getVertex(),*graph);
326 recoData->storeVerticesToRemove(result,graph);
333 if (recoData->matchOnRemovedVertices(result))
337 LWARN <<
"alternative expression ignored: "
339 <<
": overlapping with a previous one";
344 pair<Token*,MorphoSyntacticData*> newToken=
346 if (newToken.second->empty()) {
348 LERROR <<
"CreateAlternative::operator(): Got empty morphosyntactic data. Abort.";
349 delete newToken.first;
350 delete newToken.second;
359 deque<LinguisticGraphVertex> alternative;
365 bool foundHead=
false;
366 for (RecognizerMatch::const_iterator matchItr=result.begin();
367 matchItr!=result.end();
370 if (!matchItr->isKept())
380 LERROR <<
"CreateAlternative::operator() Got empty morphosyntactic data. Abort";
387 alternative.push_back(dupVx);
392 if (matchItr->getVertex()==headVertex)
396 alternative.push_back(altVertex);
402 LWARN <<
"head token has not been found in non contiguous expression. "
403 <<
"Alternative token is placed first";
404 alternative.push_front(altVertex);
410 alternative.front(),*graph);
412 deque<LinguisticGraphVertex>::const_iterator idItr=alternative.begin();
415 while (idItr!=alternative.end())
417 add_edge(lastAltVx,*idItr,*graph);
423 result.back().getVertex(),*graph);
428 recoData->storeVerticesToRemove(result,graph);
447 auto recoData= std::dynamic_pointer_cast<RecognizerData>(analysis.
getData(
"RecognizerData"));
450 LWARN <<
"StoreInData: cannot find RecognizerData in AnalysisContent";
453 recoData->addResult(result);
#define DEFAULT_ATTRIBUTE
#define LIMA_EXCEPTION(X)
This macro writes the message X to a previously configured error stream before throwing a LimaExcepti...
LinguisticGraph::in_edge_iterator LinguisticGraphInEdgeIt
boost::property_map< LinguisticGraph, vertex_data_t >::type VertexDataPropertyMap
boost::graph_traits< LinguisticGraph >::edge_descriptor LinguisticGraphEdge
typedefs to simplify the access to various graphs elements
boost::property_map< LinguisticGraph, vertex_token_t >::type VertexTokenPropertyMap
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
LinguisticGraph::out_edge_iterator LinguisticGraphOutEdgeIt
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, LinguisticVertexProperties > LinguisticGraph
Property to identify the chains in the graph.
#define CreateAlternativeId
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
std::shared_ptr< AnalysisData > getData(const QString &id)
return AnalysisData by id
Provide function to read write and check a property.
void writeValue(const LinguisticCode &value, LinguisticCode &code) const
write a property value in a coded int.
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.
const std::map< std::string, PropertyManager > & getPropertyManagers() const
Get the map of all PropertyManagers.
const PropertyAccessor & getPropertyAccessor(const std::string &propertyName) const
Get the PropertyAccessor associated to a property.
bool isCompatible(const LinguisticCode &baseProperty, const LinguisticCode &property, LinguisticCode &newProperty) const
LinguisticGraphVertex addAlternativeVertex(LinguisticAnalysisStructure::Token *, LinguisticAnalysisStructure::MorphoSyntacticData *, LinguisticGraph *graph) const
std::pair< LinguisticAnalysisStructure::Token *, LinguisticAnalysisStructure::MorphoSyntacticData * > createAlternativeToken(const Automaton::RecognizerMatch &recognizedExpression) const
Creates the new token corresponding to the idiomatic expression using information from the expression...
CreateAlternative(MediaId language, const LimaString &complement=LimaString())
void createBeginAlternative(LinguisticGraphVertex startVertex, LinguisticGraphVertex alternativeFirstVertex, LinguisticGraph &graph) const
create an alternative branch
void attachEndOfAlternative(LinguisticGraphVertex alternativeLastVertex, LinguisticGraphVertex endVertex, LinguisticGraph &graph) const
attach the end of an alternative to main path
bool getCompatibleProperties(const LinguisticAnalysisStructure::MorphoSyntacticData *headData, const LinguisticCode &baseProperty, std::set< LinguisticCode > &newProperties) const
virtual bool operator()(Automaton::RecognizerMatch &result, AnalysisContent &analysis) const override
zero-ary constraint function : applies the function without a vertex indication (used for actions,...
bool operator()(Automaton::RecognizerMatch &result, AnalysisContent &analysis) const override
zero-ary constraint function : applies the function without a vertex indication (used for actions,...
StoreInData(MediaId language, const LimaString &complement)
const EntityFeatures & features() const
LinguisticCode getLinguisticProperties() const
bool isContextual() const
LinguisticGraphVertex getHead() const
LinguisticAnalysisStructure::Token * getToken(RecognizerMatch::iterator) const
LimaString getString() const
LinguisticAnalysisStructure::MorphoSyntacticData * getHeadData() const
uint64_t positionBegin() const
LinguisticAnalysisStructure::Token * getHeadToken() const
LimaString concatString() const
bool isContiguous() const
Holds morphosyntactic informations.
holds surface data of a token
const TStatus & status() const
StringsPoolIndex form() const
void setStatus(const TStatus &status)
Set the TStatus of a token.
static const MediaticData & single()
const singleton accessor
static MediaticData & changeable()
singleton accessor
ConstraintFunctionFactory< CreateAlternative > CreateAlternativeFactory(CreateAlternativeId)
ConstraintFunctionFactory< StoreInData > StoreInDataFactory(StoreInDataId)
SimpleFactory< MediaProcessUnit, ApplyRecognizer > ApplyRecognizer(APPLYRECOGNIZER_CLASSID)
StringsPoolIndex inflectedForm
StringsPoolIndex normalizedForm
LinguisticCode properties