本文整理汇总了C++中AnnotationData::annotate方法的典型用法代码示例。如果您正苦于以下问题:C++ AnnotationData::annotate方法的具体用法?C++ AnnotationData::annotate怎么用?C++ AnnotationData::annotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnnotationData
的用法示例。
在下文中一共展示了AnnotationData::annotate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
bool CreateIdiomaticAlternative::operator()(Automaton::RecognizerMatch& result,
AnalysisContent& analysis) const
{
#ifdef DEBUG_LP
MORPHOLOGINIT;
LDEBUG << "CreateIdiomaticAlternative, match is " << result;
LDEBUG << " expression is " << (result.isContiguous()?"":"non") <<
" contiguous and" << (result.isContextual()?" non":"") << " absolute";
#endif
if (result.empty()) return false;
const LinguisticAnalysisStructure::AnalysisGraph& graph = *(result.getGraph());
AnnotationData* annotationData = static_cast< AnnotationData* >(analysis.getData("AnnotationData"));
if (annotationData->dumpFunction("IdiomExpr") == 0)
{
annotationData->dumpFunction("IdiomExpr", new DumpIdiomaticExpressionAnnotation());
}
RecognizerData* recoData=static_cast<RecognizerData*>(analysis.getData("RecognizerData"));
std::set<LinguisticGraphVertex> addedVertices;
// initialize the vertices to clear
if (result.isContiguous())
{
// MORPHOLOGINIT;
// LDEBUG << "contiguous idiomatic expression found: "
// << result.concatString();
// only one part : terms in expression are adjacent -> easy part
// check if there is an overlap first
if (recoData->matchOnRemovedVertices(result))
{
// ignore current idiomatic expression, continue
MORPHOLOGINIT;
LWARN << "idiomatic expression ignored: " << Common::Misc::limastring2utf8stdstring(result.concatString())
<< ": overlapping with a previous one";
return false;
}
// create the new token
std::pair<Token*,MorphoSyntacticData*> newToken = createAlternativeToken(result);
if (newToken.second->empty())
{
// ignore current idiomatic expression, continue
MORPHOLOGINIT;
LERROR << "CreateIdiomaticAlternative::operator() Got empty morphosyntactic data. Abort";
delete newToken.first;
delete newToken.second;
return false;
}
// add the vertex
LinguisticGraphVertex idiomaticVertex =
addAlternativeVertex(newToken.first, newToken.second, const_cast<LinguisticGraph*>(graph.getGraph()));
AnnotationGraphVertex agv = annotationData->createAnnotationVertex();
annotationData->addMatching("AnalysisGraph", idiomaticVertex, "annot", agv);
annotationData->annotate(agv, Common::Misc::utf8stdstring2limastring("AnalysisGraph"), idiomaticVertex);
IdiomaticExpressionAnnotation annot(result);
GenericAnnotation ga(annot);
annotationData->annotate(agv, Common::Misc::utf8stdstring2limastring("IdiomExpr"), ga);
addedVertices.insert(idiomaticVertex);
//create the alternative with this only vertex
createBeginAlternative(result.front().getVertex(),
idiomaticVertex,const_cast<LinguisticGraph&>(*graph.getGraph()));
attachEndOfAlternative(idiomaticVertex,
result.back().getVertex(),const_cast<LinguisticGraph&>(*graph.getGraph()));
// if expression is not contextual, only keep alternative
if (! result.isContextual())
{
recoData->storeVerticesToRemove(result,const_cast<LinguisticGraph*>(graph.getGraph()));
removeEdges(const_cast<LinguisticGraph&>(*graph.getGraph()),
result, analysis);
//recoData->setNextVertex(idiomaticVertex);
// if match was on single token, use next vertices (to avoid loops)
if (result.size() > 1)
{
recoData->setNextVertex(idiomaticVertex);
}
else
{
LinguisticGraphOutEdgeIt outItr,outItrEnd;
boost::tie(outItr,outItrEnd) = out_edges(idiomaticVertex,*(graph.getGraph()));
for (;outItr!=outItrEnd;outItr++)
{
recoData->setNextVertex(target(*outItr, *(graph.getGraph())));
}
}
}
}
else
{
// several parts : tough case
// MORPHOLOGINIT;
// LDEBUG << "non contiguous idiomatic expression found: "
// << result.concatString();
//.........这里部分代码省略.........