38namespace LinguisticProcessing
41namespace SpecificEntities
87 const TStatus& status = tokenMap[v]->status();
98 if (! complement.isEmpty()) {
107 auto recoData = std::dynamic_pointer_cast<RecognizerData>(analysis.
getData(
"RecognizerData"));
108 auto annotationData = std::dynamic_pointer_cast< AnnotationData >(analysis.
getData(
"AnnotationData"));
109 if (annotationData == 0)
113 bool annotFound =
false;
116 std::set< AnnotationGraphVertex > matches = annotationData->matches(recoData->getGraphId(),v,
"annot");
117 for (std::set< AnnotationGraphVertex >::const_iterator it = matches.begin();
118 it != matches.end(); it++)
139 for (std::set< AnnotationGraphVertex >::const_iterator it = matches.begin();
140 it != matches.end(); it++)
142 if (annotationData->annotation(*it,
166 if (!str.isEmpty()) {
168 int j=str.indexOf(sep);
170 typeName=str.left(j);
178 LDEBUG <<
"CreateSpecificEntity: getting entity type "
193getPropertyManager(
"MICRO");
199 while (currentPos != str.size()+1)
201 int sepPos = str.indexOf(sep, currentPos);
209 m_microsToKeep.insert(micro);
211 currentPos = sepPos+1;
222 LDEBUG <<
"CreateSpecificEntity: create entity of type " << match.
getType() <<
" on vertices " << match;
224 if (match.empty())
return false;
231 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.
getData(
"SyntacticData"));
233 auto annotationData = std::dynamic_pointer_cast< AnnotationData >(analysis.
getData(
"AnnotationData"));
234 if (annotationData==0)
239 if (match.size() == 1)
244 std::set< AnnotationGraphVertex > matches = annotationData->matches(graph.
getGraphId(),v1,
"annot");
245 for (std::set< AnnotationGraphVertex >::const_iterator it = matches.begin();
246 it != matches.end(); it++) {
248 && annotationData->annotation(*it,
263 if (annotationData->dumpFunction(
"SpecificEntity") == 0)
268 auto rdata = analysis.
getData(
"RecognizerData");
271 LERROR <<
"CreateSpecificEntity: missing data RecognizerData: entity will not be created";
274 auto recoData = std::dynamic_pointer_cast<RecognizerData>(rdata);
277 LERROR <<
"CreateSpecificEntity: missing data RecognizerData: entity will not be created";
280 std::string graphId=recoData->getGraphId();
286 std::ostringstream oss;
289 LDEBUG <<
"CreateSpecificEntity: annot = " << oss.str();
310 StringsPoolIndex seFlex = annot.
getString();
326 elem.
lemma = seLemma;
330 if (! m_microsToKeep.empty()) {
332 LDEBUG <<
"CreateSpecificEntity, use micros from the rule ";
335 addMicrosToMorphoSyntacticData(newMorphData,dataHead,m_microsToKeep,elem);
339 LDEBUG <<
"CreateSpecificEntity, use micros from config file ";
345 if (seType.
getGroupId() ==
static_cast<EntityGroupId
>(0))
348 LERROR <<
"CreateSpecificEntity::operator() null group id:" << seType;
356 LDEBUG <<
"Entities resource name is : " << resourceName;
359 auto entityMicros = std::dynamic_pointer_cast<SpecificEntitiesMicros>(res);
360 auto micros = entityMicros->getMicros(seType);
362 if (logger.isDebugEnabled())
364 std::ostringstream oss;
365 for (std::set<LinguisticCode>::const_iterator it=micros->begin(),it_end=micros->end();it!=it_end;it++) {
368 LDEBUG <<
"CreateSpecificEntity, micros are " << oss.str();
371 addMicrosToMorphoSyntacticData(newMorphData,dataHead,*micros,elem);
376 LERROR <<
"CreateSpecificEntity: missing resource " << resourceName ;
390 TStatus tStatus = tokenMap[head]->status();
391 const TStatus& headTStatus = tokenMap[v2]->status();
397 if (newMorphData->empty())
400 LERROR <<
"CreateSpecificEntity::operator() Found no morphosyntactic data for new vertex. Abort.";
410 if (syntacticData != 0)
412 boost::tie (newVertex, newDepVertex) = syntacticData->addVertex();
416 newVertex = add_vertex(*lingGraph);
419 annotationData->addMatching(graphId, newVertex,
"annot", agv);
421 tokenMap[newVertex] = newToken;
422 dataMap[newVertex] = newMorphData;
424 LDEBUG <<
" - new vertex " << newVertex <<
"("<<graphId<<
"), " << newDepVertex
425 <<
"(dep), " << agv <<
"(annot) added";
434 Automaton::RecognizerMatch::const_iterator matchIt, matchIt_end;
435 matchIt = match.begin(); matchIt_end = match.end();
436 for (; matchIt != matchIt_end; matchIt++)
438 std::set< AnnotationGraphVertex > matches = annotationData->matches(graphId,(*matchIt).m_elem.first,
"annot");
442 LERROR <<
"CreateSpecificEntity::operator() No annotation 'annot' for" << (*matchIt).m_elem.first;
446 if( recoData->hasVertexAsEmbededEntity((*matchIt).m_elem.first) )
449 LDEBUG <<
"CreateSpecificEntity::operator(): vertex " << *(matches.begin()) <<
" is embeded";
459 std::vector< LinguisticGraphVertex > previous;
461 boost::tie(firstInEdgesIt, firstInEdgesIt_end) = in_edges(v1, *lingGraph);
462 std::set< std::pair<LinguisticGraphVertex,LinguisticGraphVertex > > newEdgesToRemove;
463 for (; firstInEdgesIt != firstInEdgesIt_end; firstInEdgesIt++)
466 previous.push_back(firstInVertex);
467 if (shouldRemoveInitial(source(*firstInEdgesIt, *lingGraph),target(*firstInEdgesIt, *lingGraph), match))
470 LDEBUG <<
" - storing edge " << source(*firstInEdgesIt, *lingGraph) <<
" -> "<<target(*firstInEdgesIt, *lingGraph) <<
" to be removed";
473 newEdgesToRemove.insert(std::make_pair(source(*firstInEdgesIt, *lingGraph),target(*firstInEdgesIt, *lingGraph)));
478 LDEBUG <<
" - do not store initial edge " << source(*firstInEdgesIt, *lingGraph) <<
" -> "<<target(*firstInEdgesIt, *lingGraph) <<
" to be removed";
482 std::vector< LinguisticGraphVertex >::iterator pit, pit_end;
483 pit = previous.begin(); pit_end = previous.end();
484 for (; pit != pit_end; pit++)
488 if (!recoData->isEdgeToBeRemoved(*pit, v1))
492 boost::tie(e, success) = add_edge(*pit, newVertex, *lingGraph);
496 LDEBUG <<
" - in edge " << e.m_source <<
" -> " << e.m_target <<
" added";
502 LERROR <<
" - in edge " << *pit <<
" ->" << newVertex <<
" NOT added";
508 LDEBUG <<
" - edge " << *pit <<
" - " << newVertex <<
" not added because " << *pit <<
" - " << v1 <<
" has to be removed";
512 std::set< std::pair<LinguisticGraphVertex,LinguisticGraphVertex > >::iterator newEdgesToRemoveIt = newEdgesToRemove.begin();
513 for (; newEdgesToRemoveIt != newEdgesToRemove.end(); newEdgesToRemoveIt++)
515 recoData->setEdgeToBeRemoved(analysis, edge( newEdgesToRemoveIt->first, newEdgesToRemoveIt->second, *lingGraph).first);
518 LDEBUG <<
" - in edges added";
524 LDEBUG <<
" there is " << out_degree(v2, *lingGraph) <<
" edges out of " << v2;
527 boost::tie(secondOutEdgesIt, secondOutEdgesIt_end) = out_edges(v2, *lingGraph);
528 std::vector< LinguisticGraphVertex > nexts;
529 for (; secondOutEdgesIt != secondOutEdgesIt_end; secondOutEdgesIt++)
532 LDEBUG <<
" looking at edge " << source(*secondOutEdgesIt, *lingGraph) <<
" -> " << target(*secondOutEdgesIt, *lingGraph);
535 if (secondOutVertex == v2)
continue;
536 nexts.push_back(secondOutVertex);
537 if (shouldRemoveFinal(source(*secondOutEdgesIt, *lingGraph),target(*secondOutEdgesIt, *lingGraph), match))
540 LDEBUG <<
" - storing edge " << source(*secondOutEdgesIt, *lingGraph) <<
" -> " << target(*secondOutEdgesIt, *lingGraph) <<
" to be removed";
542 recoData->setEdgeToBeRemoved(analysis, *secondOutEdgesIt);
547 LDEBUG <<
" - do not store final edge " << source(*secondOutEdgesIt, *lingGraph) <<
" -> " << target(*secondOutEdgesIt, *lingGraph) <<
" to be removed";
551 std::vector< LinguisticGraphVertex >::iterator nit, nit_end;
552 nit = nexts.begin(); nit_end = nexts.end();
553 for (; nit != nit_end; nit++)
557 boost::tie(e, success) = add_edge(newVertex, *nit, *lingGraph);
561 LDEBUG <<
" - out edge " << e.m_source <<
" -> " << e.m_target <<
" added";
567 LERROR <<
" - out edge " << newVertex <<
" ->" << *nit <<
" NOT added";
571 LDEBUG <<
" - out edges added";
575 recoData->removeEdges( analysis );
589 boost::tie(outItr,outItrEnd) = out_edges(newVertex,*lingGraph);
590 for (;outItr!=outItrEnd;outItr++)
592 recoData->setNextVertex(target(*outItr, *lingGraph));
595 RecognizerMatch::const_iterator matchItr=match.begin();
596 for (; matchItr!=match.end(); matchItr++)
598 recoData->clearUnreachableVertices( analysis, (*matchItr).getVertex());
606 const std::set<LinguisticCode>& micros,
610 for (MorphoSyntacticData::const_iterator it=oldMorphData->begin(),
611 it_end=oldMorphData->end(); it!=it_end; it++) {
613 if (micros.find(m_microAccessor->
readValue((*it).properties)) !=
616 newMorphData->push_back(elem);
620 if (newMorphData->empty()) {
621 for (std::set<LinguisticCode>::const_iterator it=micros.begin(),
622 it_end=micros.end(); it!=it_end; it++) {
624 newMorphData->push_back(elem);
629bool CreateSpecificEntity::shouldRemoveInitial(
637 if (match.size() == 1)
643 std::set< LinguisticGraphVertex > matchVertices;
644 Automaton::RecognizerMatch::const_iterator matchIt, matchIt_end;
646 matchIt = match.begin();
647 matchIt_end = match.end();
648 for (; matchIt != matchIt_end; matchIt++)
650 matchVertices.insert((*matchIt).m_elem.first);
653 matchIt = match.begin();
654 matchIt_end = match.end()-1;
655 if (boost::out_degree((*matchIt).m_elem.first,*graph.
getGraph()) > 1)
658 LDEBUG <<
"removing edge (" << (*matchIt).m_elem.first <<
"," << (*(matchIt+1)).m_elem.first <<
") because there is more than one path from the first vertex of the match.";
660 boost::remove_edge((*matchIt).m_elem.first,(*(matchIt+1)).m_elem.first, *
const_cast<LinguisticGraph*
>(graph.
getGraph()));
664 for (; matchIt != matchIt_end; matchIt++)
666 if (boost::out_degree((*matchIt).m_elem.first,*graph.
getGraph()) > 1)
669 boost::tie (outIt, outIt_end) = boost::out_edges((*matchIt).m_elem.first, *graph.
getGraph());
670 for (; outIt != outIt_end; outIt++)
672 if (matchVertices.find(source(*outIt, *graph.
getGraph())) != matchVertices.end())
686bool CreateSpecificEntity::shouldRemoveFinal(
694 if (match.size() == 1)
700 std::set< LinguisticGraphVertex > matchVertices;
701 Automaton::RecognizerMatch::const_iterator matchIt, matchIt_end;
703 matchIt = match.begin();
704 matchIt_end = match.end();
705 for (; matchIt != matchIt_end; matchIt++)
707 matchVertices.insert((*matchIt).m_elem.first);
710 matchIt = match.begin()+1;
711 matchIt_end = match.end();
712 for (; matchIt != matchIt_end; matchIt++)
714 if (boost::in_degree((*matchIt).m_elem.first,*graph.
getGraph()) > 1)
717 boost::tie (inIt, inIt_end) = boost::in_edges((*matchIt).m_elem.first, *graph.
getGraph());
718 for (; inIt != inIt_end; inIt++)
720 if (matchVertices.find(source(*inIt, *graph.
getGraph())) != matchVertices.end())
723 LDEBUG <<
"removing final edge " << source(*inIt, *graph.
getGraph()) <<
" -> " << target(*inIt, *graph.
getGraph());
750m_featureType(QVariant::String)
752 if (complement.size()) {
753 QStringList complementElements = complement.split(
":");
754 m_featureName=complementElements.front().toUtf8().constData();
755 complementElements.pop_front();
756 if (!complementElements.empty()) {
757 const QString& complementType = complementElements.front();
758 m_featureType = QVariant::nameToType(complementType.toUtf8().constData());
759 if (m_featureType != QVariant::Invalid) {
760 if (complementType ==
"int") {
761 m_featureType = QVariant::Int;
763 else if (complementType ==
"double") {
764 m_featureType = QVariant::Double;
767 m_featureType = QVariant::String;
781 LDEBUG <<
"SetEntityFeature:: (one argument) start... ";
782 LDEBUG <<
"SetEntityFeature::(feature:" << m_featureName <<
", vertex:" << vertex <<
")";
785 auto recoData = std::dynamic_pointer_cast<RecognizerData>(analysis.
getData(
"RecognizerData"));
788 LERROR <<
"SetEntityFeature:: Error: missing RecognizerData";
799 if (token ==
nullptr)
805 switch (m_featureType) {
806 case QVariant::String:
808 LDEBUG <<
"SetEntityFeature:: recoData->setEntityFeature(feature:" << m_featureName <<
", featureValue:" << featureValue<<
")";
810 recoData->setEntityFeature(m_featureName,featureValue);
814 LDEBUG <<
"SetEntityFeature:: recoData->setEntityFeature(feature:" << m_featureName <<
", featureValue:" << featureValue.toInt() <<
")";
816 recoData->setEntityFeature(m_featureName,featureValue.toInt());
818 case QVariant::Double:
820 LDEBUG <<
"SetEntityFeature:: recoData->setEntityFeature(feature:" << m_featureName <<
", featureValue:" << featureValue.toDouble() <<
")";
822 recoData->setEntityFeature(m_featureName,featureValue.toDouble());
825 recoData->setEntityFeature(m_featureName,featureValue);
827 uint64_t pos = (int64_t)(token->
position());
828 uint64_t len = (int64_t)(token->
length());
831 std::vector<EntityFeature>::iterator featureIt =
832 features.
find(m_featureName);
833 if( featureIt != recoData->getEntityFeatures().end() )
835 featureIt->setPosition(pos);
836 featureIt->setLength(len);
850 LDEBUG <<
"SetEntityFeature:: (two arguments) start... ";
851 LDEBUG <<
"SetEntityFeature::(feature:" << m_featureName <<
", v1:" << v1 <<
", v2:" << v2 <<
")";
855 auto recoData = std::dynamic_pointer_cast<RecognizerData>(analysis.
getData(
"RecognizerData"));
858 LERROR <<
"SetEntityFeature:: Error: missing RecognizerData";
869 std::queue<LinguisticGraphVertex> toVisit;
870 std::set<LinguisticGraphVertex> visited;
876 unsigned int nbEdges(0);
877 while (!toVisit.empty()) {
881 for (boost::tie(outItr,outItrEnd)=out_edges(v,lGraph); outItr!=outItrEnd; outItr++)
884 if (visited.find(next)==visited.end())
886 visited.insert(next);
894 LWARN <<
"SetEntityFeature:: Warning: ambiguities in graph";
903 len = (int64_t)(token->
position()) - pos + 1 + (int64_t)(token->
length());
910 switch (m_featureType) {
911 case QVariant::String:
912 recoData->setEntityFeature(m_featureName,featureValue);
915 recoData->setEntityFeature(m_featureName,featureValue.toInt());
917 case QVariant::Double:
918 recoData->setEntityFeature(m_featureName,featureValue.toDouble());
921 recoData->setEntityFeature(m_featureName,featureValue);
924 std::vector<EntityFeature>::iterator featureIt =
925 features.
find(m_featureName);
926 if( featureIt != recoData->getEntityFeatures().end() )
928 featureIt->setPosition(pos);
929 featureIt->setLength(len);
946 if (complement.size()) {
947 QStringList complementElements = complement.split(
":");
948 m_featureName=complementElements.front().toUtf8().constData();
949 complementElements.pop_front();
950 if (!complementElements.empty()) {
953 LERROR <<
"AddEntityFeatureAsEntity::AddEntityFeatureAsEntity(): no type specification authorized for the feature ("
954 << complementElements <<
") the feature type is the type of the entity";
967 LDEBUG <<
"AddEntityFeatureAsEntity:: (one argument) start... ";
968 LDEBUG <<
"AddEntityFeatureAsEntity::(feature:" << m_featureName <<
", vertex:" << vertex <<
")";
971 auto recoData = std::dynamic_pointer_cast<RecognizerData>(analysis.
getData(
"RecognizerData"));
974 LERROR <<
"AddEntityFeatureAsEntity:: Error: missing RecognizerData";
978 recoData->addVertexAsEmbededEntity(vertex);
995m_featureType(QVariant::String)
997 if (complement.size()) {
998 QStringList complementElements = complement.split(
":");
999 m_featureName=complementElements.front().toUtf8().constData();
1000 complementElements.pop_front();
1001 if (!complementElements.empty()) {
1002 const QString& complementType = complementElements.front();
1003 m_featureType = QVariant::nameToType(complementType.toUtf8().constData());
1004 if (m_featureType != QVariant::Invalid) {
1005 if (complementType ==
"int") {
1006 m_featureType = QVariant::Int;
1008 else if (complementType ==
"double") {
1009 m_featureType = QVariant::Double;
1012 m_featureType = QVariant::String;
1026 LDEBUG <<
"AddEntityFeature:: (one argument) start... ";
1027 LDEBUG <<
"AddEntityFeature::(feature:" << m_featureName <<
", vertex:" << vertex <<
")";
1030 auto recoData = std::dynamic_pointer_cast<RecognizerData>(analysis.
getData(
"RecognizerData"));
1033 LERROR <<
"AddEntityFeature:: Error: missing RecognizerData";
1044 if (token ==
nullptr)
1050 switch (m_featureType) {
1051 case QVariant::String:
1053 LDEBUG <<
"AddEntityFeature:: recoData->addEntityFeature(feature:" << m_featureName <<
", featureValue:" << featureValue<<
")";
1055 recoData->addEntityFeature(m_featureName,featureValue);
1059 LDEBUG <<
"AddEntityFeature:: recoData->addEntityFeature(feature:" << m_featureName <<
", featureValue:" << featureValue.toInt()<<
")";
1061 recoData->addEntityFeature(m_featureName,featureValue.toInt());
1063 case QVariant::Double:
1065 LDEBUG <<
"AddEntityFeature:: recoData->addEntityFeature(feature:" << m_featureName <<
", featureValue:" << featureValue.toDouble()<<
")";
1067 recoData->addEntityFeature(m_featureName,featureValue.toDouble());
1070 recoData->addEntityFeature(m_featureName,featureValue);
1072 uint64_t pos = (int64_t)(token->
position());
1073 uint64_t len = (int64_t)(token->
length());
1076 std::vector<EntityFeature>::iterator featureIt =
1078 if( featureIt != recoData->getEntityFeatures().end() )
1080 featureIt->setPosition(pos);
1081 featureIt->setLength(len);
1095 LDEBUG <<
"AddEntityFeature:: (two arguments) start... ";
1096 LDEBUG <<
"AddEntityFeature::(feature:" << m_featureName <<
", v1:" << v1 <<
", v2:" << v2 <<
")";
1100 auto recoData = std::dynamic_pointer_cast<RecognizerData>(analysis.
getData(
"RecognizerData"));
1103 LERROR <<
"AddEntityFeature:: Error: missing RecognizerData";
1114 std::queue<LinguisticGraphVertex> toVisit;
1115 std::set<LinguisticGraphVertex> visited;
1121 unsigned int nbEdges(0);
1122 while (!toVisit.empty()) {
1126 for (boost::tie(outItr,outItrEnd)=out_edges(v,lGraph); outItr!=outItrEnd; outItr++)
1129 if (visited.find(next)==visited.end())
1131 visited.insert(next);
1139 LWARN <<
"AddEntityFeature:: Warning: ambiguities in graph";
1144 pos = (int64_t)(token->
position());
1148 len = (int64_t)(token->
position()) - pos + 1 + (int64_t)(token->
length());
1155 switch (m_featureType) {
1156 case QVariant::String:
1157 recoData->setEntityFeature(m_featureName,featureValue);
1160 recoData->setEntityFeature(m_featureName,featureValue.toInt());
1162 case QVariant::Double:
1163 recoData->setEntityFeature(m_featureName,featureValue.toDouble());
1166 recoData->setEntityFeature(m_featureName,featureValue);
1169 std::vector<EntityFeature>::iterator featureIt =
1171 if( featureIt != recoData->getEntityFeatures().end() )
1173 featureIt->setPosition(pos);
1174 featureIt->setLength(len);
1189m_featureType(QVariant::String)
1191 if (complement.size()) {
1192 QStringList complementElements = complement.split(
":");
1193 m_featureName=complementElements.front().toUtf8().constData();
1194 complementElements.pop_front();
1195 if (!complementElements.empty()) {
1196 const QString& complementType = complementElements.front();
1197 m_featureType = QVariant::nameToType(complementType.toUtf8().constData());
1198 if (m_featureType != QVariant::Invalid) {
1199 if (complementType ==
"int") {
1200 m_featureType = QVariant::Int;
1202 else if (complementType ==
"double") {
1203 m_featureType = QVariant::Double;
1206 m_featureType = QVariant::String;
1240 LDEBUG <<
"AppendEntityFeature::() (one argument) start... ";
1241 LDEBUG <<
"AppendEntityFeature::() feature:" << m_featureName <<
", vertex:" << vertex <<
")";
1244 auto recoData = std::dynamic_pointer_cast<RecognizerData>(analysis.
getData(
"RecognizerData"));
1247 LERROR <<
"AppendEntityFeature::() Error: missing RecognizerData";
1258 std::vector<EntityFeature>::iterator featureIt = features.
find(m_featureName);
1262 if( featureIt != recoData->getEntityFeatures().end() )
1264 pos =
minPos( featureIt->getPosition(), (int64_t)(token->
position()) );
1266 LDEBUG <<
"AppendEntityFeature::() minPos=" << pos;
1270 maxPos1 = featureIt->getPosition() + featureIt->getLength();
1273 LDEBUG <<
"AppendEntityFeature::() maxPos1=" << maxPos1;
1275 uint64_t maxPos2 = (int64_t)(token->
position()) + (int64_t)(token->
length());
1277 LDEBUG <<
"AppendEntityFeature::() maxPos2=" << maxPos2;
1279 uint64_t maxPos3 =
maxPos( maxPos1, maxPos2 );
1281 LDEBUG <<
"AppendEntityFeature::() maxPos3=" << maxPos3;
1283 len = maxPos3 - pos;
1285 LDEBUG <<
"AppendEntityFeature::() len=" << len;
1289 pos = (int64_t)(token->
position());
1290 len = (int64_t)(token->
length());
1301 switch (m_featureType) {
1302 case QVariant::String:
1303 recoData->appendEntityFeature(m_featureName,featureValue);
1306 recoData->appendEntityFeature(m_featureName,featureValue.toInt());
1308 case QVariant::Double:
1309 recoData->appendEntityFeature(m_featureName,featureValue.toDouble());
1312 recoData->appendEntityFeature(m_featureName,featureValue);
1314 featureIt = features.
find(m_featureName);
1316 LDEBUG <<
"AppendEntityFeature::() pos before = ("
1317 << featureIt->getPosition() <<
","
1318 << featureIt->getLength() <<
")";
1320 featureIt->setPosition(pos);
1321 featureIt->setLength(len);
1323 LDEBUG <<
"AppendEntityFeature::() pos after = (" << pos <<
"," << len <<
")";
1339 auto recoData = std::dynamic_pointer_cast<RecognizerData>(analysis.
getData(
"RecognizerData"));
1341 recoData->clearEntityFeatures();
1358 auto recoData = std::dynamic_pointer_cast<RecognizerData>(analysis.
getData(
"RecognizerData"));
1359 if (recoData ==
nullptr) {
1361 LERROR <<
"NormalizeEntity:: Error: missing RecognizerData";
1366 const auto& features = recoData->getEntityFeatures();
1367 for (
auto it = features.cbegin(); it != features.cend(); ++it) {
1371 (*featureIt).setPosition(it->getPosition());
1372 (*featureIt).setLength(it->getLength());
1376 recoData->clearEntityFeatures();
This file is the main header file for the data related to annotation graphs.
DependencyGraph::vertex_descriptor DependencyGraphVertex
#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 SetEntityFeatureId
#define CreateSpecificEntityId
#define isAlphaPossessiveId
#define NormalizeEntityId
#define ClearEntityFeaturesId
#define AddEntityFeatureId
#define isASpecificEntityId
#define AppendEntityFeatureId
#define AddEntityFeatureAsEntityId
Data used for the syntactic analyzis of texts.
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
This class allows to convert any object into an annotation by inheritance.
LinguisticCode readValue(const LinguisticCode &code) const
read a property in a coded int.
Provide tools to manage a specific property.
LinguisticCode getPropertyValue(const std::string &symbolicValue) const
Get the coded property value from the symbolic value.
The main LIMA exception class.
virtual const char * what() const override
a list of generic features: each feature is unique (only one feature for a name)
EntityFeatures::const_iterator findLast(const std::string &featureName) const
void addFeature(const std::string &name, const ValueType &value)
EntityFeatures::const_iterator find(const std::string &featureName) const
const EntityFeatures & features() const
const Common::MediaticData::EntityType & getType() const
const LinguisticAnalysisStructure::AnalysisGraph * getGraph() const
uint64_t positionBegin() const
An AnalysisData containing a LinguisticGraph with a language and an id.
const std::string & getGraphId(void) const
const LinguisticGraph * getGraph(void) const
Returns the underlying graph structure.
Holds morphosyntactic informations.
bool isAlphaPossessive() const
void setAlphaPossessive(bool isAlphaPossessive)
holds surface data of a token
uint64_t position() const
const LimaString & stringForm() const
void setStatus(const TStatus &status)
Set the TStatus of a token.
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &vertex, AnalysisContent &analysis) const override
unary constraint function : the constraint only applies on one vertices in the graph (the graph is al...
AddEntityFeatureAsEntity(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &vertex, AnalysisContent &analysis) const override
unary constraint function : the constraint only applies on one vertices in the graph (the graph is al...
AddEntityFeature(MediaId language, const LimaString &complement=LimaString())
uint64_t maxPos(const uint64_t pos1, const uint64_t pos2) const
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &vertex, AnalysisContent &analysis) const override
unary constraint function : the constraint only applies on one vertices in the graph (the graph is al...
uint64_t minPos(const uint64_t pos1, const uint64_t pos2) const
AppendEntityFeature(MediaId language, const LimaString &complement=LimaString())
ClearEntityFeatures(MediaId language, const LimaString &complement=LimaString())
bool operator()(AnalysisContent &analysis) const override
zero-ary constraint function : applies the function without a vertex indication (used for actions,...
CreateSpecificEntity(MediaId language, const LimaString &complement=LimaString())
bool operator()(Automaton::RecognizerMatch &match, AnalysisContent &analysis) const override
Definition of a function suitable to be used as a dumper for specific entities annotations of an anno...
NormalizeEntity(MediaId language, const LimaString &complement=LimaString())
bool operator()(Automaton::RecognizerMatch &match, AnalysisContent &analysis) const override
zero-ary constraint function : applies the function without a vertex indication (used for actions,...
SetEntityFeature(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &vertex, AnalysisContent &analysis) const override
unary constraint function : the constraint only applies on one vertices in the graph (the graph is al...
A representation of a specific entity to store in the annotation graph.
StringsPoolIndex getString() const
LinguisticGraphVertex getHead() const
void dump(std::ostream &os) const
The functions that dumps a SpecificEntityAnnotation on an output stream.
StringsPoolIndex getNormalizedForm() const
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...
isASpecificEntity(MediaId language, const LimaString &complement=LimaString())
isAlphaPossessive(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...
static const MediaticData & single()
const singleton accessor
static MediaticData & changeable()
singleton accessor
AnnotationGraph::vertex_descriptor AnnotationGraphVertex
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< AddEntityFeatureAsEntity > AddEntityFeatureAsEntityFactory(AddEntityFeatureAsEntityId)
ConstraintFunctionFactory< AppendEntityFeature > AppendEntityFeatureFactory(AppendEntityFeatureId)
ConstraintFunctionFactory< ClearEntityFeatures > ClearEntityFeaturesFactory(ClearEntityFeaturesId)
ConstraintFunctionFactory< isAlphaPossessive > isAlphaPossessiveFactory(isAlphaPossessiveId)
ConstraintFunctionFactory< NormalizeEntity > NormalizeEntityFactory(NormalizeEntityId)
ConstraintFunctionFactory< CreateSpecificEntity > CreateSpecificEntityFactory(CreateSpecificEntityId)
ConstraintFunctionFactory< isASpecificEntity > isASpecificEntityFactory(isASpecificEntityId)
ConstraintFunctionFactory< SetEntityFeature > SetEntityFeatureFactory(SetEntityFeatureId)
ConstraintFunctionFactory< AddEntityFeature > AddEntityFeatureFactory(AddEntityFeatureId)
StringsPoolIndex inflectedForm
StringsPoolIndex normalizedForm
LinguisticCode properties