本文整理汇总了C++中Lattice::edgesSortedBySource方法的典型用法代码示例。如果您正苦于以下问题:C++ Lattice::edgesSortedBySource方法的具体用法?C++ Lattice::edgesSortedBySource怎么用?C++ Lattice::edgesSortedBySource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lattice
的用法示例。
在下文中一共展示了Lattice::edgesSortedBySource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addPosEdges
void RuleMatcher::addPosEdges(Lattice &lattice) {
LayerTagMask mask = lattice.getLayerTagManager().getMask(
lattice.getLayerTagManager().
createSingletonTagCollection("form")
);
std::multimap<Lattice::VertexDescriptor, std::string> posEdgesMap;
Lattice::EdgesSortedBySourceIterator edgeIterator =
lattice.edgesSortedBySource(mask);
while (edgeIterator.hasNext()) {
Lattice::EdgeDescriptor edge = edgeIterator.next();
int start = lattice.getEdgeBeginIndex(edge);
int end = start + lattice.getEdgeLength(edge);
AnnotationItem annotationItem = lattice.getEdgeAnnotationItem(edge);
if (lattice::isDiscarded(lattice, edge))
continue; //skip discarded forms
std::string partOfSpeech = lattice::getPartOfSpeech(lattice, edge);
std::pair<
std::multimap<Lattice::VertexDescriptor, std::string>::iterator,
std::multimap<Lattice::VertexDescriptor, std::string>::iterator
> posEdgesMapIt =
posEdgesMap.equal_range(start);
bool alreadyAdded = false;
if (posEdgesMapIt.first != posEdgesMapIt.second) {
while (posEdgesMapIt.first != posEdgesMapIt.second) {
if (posEdgesMapIt.first->second ==
partOfSpeech) {
alreadyAdded = true;
break;
}
posEdgesMapIt.first ++;
}
}
if (! alreadyAdded) {
AnnotationItem ai(partOfSpeech);
lattice.getAnnotationItemManager().setValue(ai, "discard", "0");
lattice.getAnnotationItemManager().setValue(ai, "head", "0");
Lattice::EdgeSequence::Builder seqBuilder(lattice);
seqBuilder.addEdge(edge);
lattice.addEdge(
start,
end,
ai,
lattice.getLayerTagManager().
createSingletonTagCollection("parse"),
seqBuilder.build()
);
posEdgesMap.insert(std::pair< Lattice::VertexDescriptor, std::string>(
start, partOfSpeech));
}
}
}