本文整理汇总了C++中AnnotationData::matches方法的典型用法代码示例。如果您正苦于以下问题:C++ AnnotationData::matches方法的具体用法?C++ AnnotationData::matches怎么用?C++ AnnotationData::matches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnnotationData
的用法示例。
在下文中一共展示了AnnotationData::matches方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
bool EntityGroupTransition::
compare(const LinguisticAnalysisStructure::AnalysisGraph& graph,
const LinguisticGraphVertex& v,
AnalysisContent& analysis,
const LinguisticAnalysisStructure::Token* /*token*/,
const LinguisticAnalysisStructure::MorphoSyntacticData* /*data*/) const
{
// should compare to vertex ?
AnnotationData* annotationData = static_cast< AnnotationData* >(analysis.getData("AnnotationData"));
if (annotationData==0) {
AULOGINIT;
LDEBUG << "EntityGroupTransition::compare: no annotation graph available !";
return false;
}
// find annotationGraphVertex matching the vertex of the current graph
std::set<AnnotationGraphVertex> matches = annotationData->matches(graph.getGraphId(), v, "annot");
if (matches.empty())
{
AULOGINIT;
LDEBUG << "annotation ("<<graph.getGraphId()<<", "<<v<<", \"annot\") available";
return false;
}
AnnotationGraphVertex annotVertex = *(matches.begin());
if (!annotationData->hasAnnotation(annotVertex, m_entityAnnotation))
{
AULOGINIT;
LDEBUG << "EntityGroupTransition::compare: No " << m_entityAnnotation << " annotation available on " << v;
return false;
}
const SpecificEntityAnnotation* se =
annotationData->annotation(annotVertex, m_entityAnnotation).
pointerValue<SpecificEntityAnnotation>();
Common::MediaticData::EntityType type = se->getType();
AULOGINIT;
LDEBUG << "EntityGroupTransition::compare: type = " << type << ", groupId = " << type.getGroupId();
LDEBUG << "EntityGroupTransition::compare: m_entityGroupId = " << m_entityGroupId;
LDEBUG << "EntityGroupTransition::compare: tests m_entityGroupId == type.getGroupId() = " << (m_entityGroupId == type.getGroupId());
return( m_entityGroupId == type.getGroupId() );
}
示例2: process
LimaStatusCode EntityTracker::process(AnalysisContent& analysis) const
{
TimeUtils::updateCurrentTime();
SELOGINIT;
LinguisticMetaData* metadata=static_cast<LinguisticMetaData*>(analysis.getData("LinguisticMetaData"));
if (metadata == 0)
{
LERROR << "no LinguisticMetaData ! abort" << LENDL;
return MISSING_DATA;
}
AnalysisGraph* anagraph=static_cast<AnalysisGraph*>(analysis.getData("AnalysisGraph"));
if (anagraph==0)
{
LERROR << "no graph 'AnaGraph' available !" << LENDL;
return MISSING_DATA;
}
AnnotationData* annotationData = static_cast< AnnotationData* >(analysis.getData("AnnotationData"));
if (annotationData==0)
{
LERROR << "no annotation graph available !" << LENDL;
return MISSING_DATA;
}
// add new data to store co-references
CoreferenceData* corefData = new CoreferenceData;
analysis.setData("CoreferenceData",corefData);
CoreferenceEngine ref;
LinguisticGraph* graph=anagraph->getGraph();
LinguisticGraphVertex lastVertex=anagraph->lastVertex();
LinguisticGraphVertex firstVertex=anagraph->firstVertex();
std::queue<LinguisticGraphVertex> toVisit;
std::set<LinguisticGraphVertex> visited;
LinguisticGraphOutEdgeIt outItr,outItrEnd;
// output vertices between begin and end,
// but do not include begin (beginning of text or previous end of sentence) and include end (end of sentence)
toVisit.push(firstVertex);
bool first=true;
bool last=false;
while (!toVisit.empty()) {
LinguisticGraphVertex v=toVisit.front();
toVisit.pop();
if (last || v == lastVertex) {
continue;
}
if (v == lastVertex) {
last=true;
}
for (boost::tie(outItr,outItrEnd)=out_edges(v,*graph); outItr!=outItrEnd; outItr++)
{
LinguisticGraphVertex next=target(*outItr,*graph);
if (visited.find(next)==visited.end())
{
visited.insert(next);
toVisit.push(next);
}
}
if (first) {
first=false;
}
else {
// first, check if vertex corresponds to a specific entity
std::set< AnnotationGraphVertex > matches = annotationData->matches("AnalysisGraph",v,"annot");
for (std::set< AnnotationGraphVertex >::const_iterator it = matches.begin();
it != matches.end(); it++)
{
AnnotationGraphVertex vx=*it;
Token* t=get(vertex_token,*graph,vx);
/* sauvegarde de tous les vertex */
if (t != 0)
{
//storeAllToken(t);
//allToken.push_back(t);
ref.storeAllToken(*t);
}
if (annotationData->hasAnnotation(vx, Common::Misc::utf8stdstring2limastring("SpecificEntity")))
{
/*const SpecificEntityAnnotation* se =
annotationData->annotation(vx, Common::Misc::utf8stdstring2limastring("SpecificEntity")).
pointerValue<SpecificEntityAnnotation>();*/
//storeSpecificEntity(se);
//Token* t=get(vertex_token,*graph,vx);
//storedAnnotations.push_back(*t);
ref.storeAnnot(*t);
// std::cout<< "le vertex de nom "<< t->stringForm()<<std::endl;
}
}
}
}
/* recherche des coréferences entre les entitées nommées précédemment détectées */
//.........这里部分代码省略.........
示例3: operator
//.........这里部分代码省略.........
bool keeping = false;
std::pair< LinguisticGraphVertex, LinguisticGraphVertex > idiomPartBounds;
std::set< std::pair< LinguisticGraphVertex, LinguisticGraphVertex > > edgesToRemove;
RecognizerMatch::const_iterator matchItr=result.begin();
for (; matchItr!=result.end(); matchItr++)
{
if (!matchItr->isKept())
{
if (keeping)
{
RecognizerMatch::const_iterator prevItr = matchItr - 1;
idiomPartBounds.second = prevItr->getVertex();
keeping = false;
#ifdef DEBUG_LP
LDEBUG << "adding " << idiomPartBounds.first << " -> " << idiomPartBounds.second << " in edgesToRemove";
#endif
edgesToRemove.insert(idiomPartBounds);
}
// duplicate this vertex
#ifdef DEBUG_LP
LDEBUG << "duplication of vertex " << matchItr->getVertex();;
#endif
Token* token=get(vertex_token,*graph.getGraph(),matchItr->getVertex());
MorphoSyntacticData* data =
new MorphoSyntacticData(*get(vertex_data,*graph.getGraph(),matchItr->getVertex()));
LinguisticGraphVertex dupVx = add_vertex(const_cast<LinguisticGraph&>(*graph.getGraph()));
put(vertex_token,const_cast<LinguisticGraph&>(*graph.getGraph()),dupVx,token);
put(vertex_data,const_cast<LinguisticGraph&>(*graph.getGraph()),dupVx,data);
idiomAlternative.push_back(dupVx);
AnnotationGraphVertex agv = annotationData->createAnnotationVertex();
annotationData->addMatching("AnalysisGraph", dupVx, "annot", agv);
annotationData->annotate(agv, Common::Misc::utf8stdstring2limastring("AnalysisGraph"), dupVx);
std::set< LinguisticGraphVertex > annotMatches =
annotationData->matches("AnalysisGraph",matchItr->getVertex(),"annot");
for (std::set< LinguisticGraphVertex >::const_iterator annotIt(annotMatches.begin());
annotIt != annotMatches.end(); annotIt++)
{
std::set< std::string > excepted;
excepted.insert("AnalysisGraph");
annotationData->cloneAnnotations(*annotIt, agv, excepted);
}
addedVertices.insert(dupVx);
// verticesToRemove.insert(matchItr->getVertex());
}
else
{
if (!keeping)
{
idiomPartBounds.first = matchItr->getVertex();
keeping = true;
}
#ifdef DEBUG_LP
LDEBUG << "kept vertex " << matchItr->getVertex();
#endif
if (matchItr->getVertex()==headVertex)
{
foundHead=true;
#ifdef DEBUG_LP
LDEBUG << "add head vertex " << idiomaticVertex;
#endif
idiomAlternative.push_back(idiomaticVertex);
}
}
}
if (!foundHead)
{