本文整理汇总了C++中LabelSet类的典型用法代码示例。如果您正苦于以下问题:C++ LabelSet类的具体用法?C++ LabelSet怎么用?C++ LabelSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LabelSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLabelSet
LabelSet Labeler::getLabelSet(set<SgNode*>& nodeSet) {
LabelSet lset;
for(set<SgNode*>::iterator i=nodeSet.begin();i!=nodeSet.end();++i) {
lset.insert(getLabel(*i));
}
return lset;
}
示例2:
LabelSet LabelSet::operator+(LabelSet& s2) {
LabelSet result;
result=*this;
for(LabelSet::iterator i2=s2.begin();i2!=s2.end();++i2)
result.insert(*i2);
return result;
}
示例3: controlDependenceGraph
Flow CFAnalysis::controlDependenceGraph(Flow& controlFlow) {
LabelSet condLabels=conditionLabels(controlFlow);
LabelSet targetLabels;
Flow controlDependenceEdges;
for(LabelSet::iterator i=condLabels.begin();i!=condLabels.end();++i) {
SgNode* condition=getLabeler()->getNode(*i);
cerr<<"DEBUG: cond:"<<condition->class_name()<<endl;
SgNode* stmt=SgNodeHelper::getParent(condition);
cerr<<"DEBUG: stmt:"<<stmt->class_name()<<endl;
// while/dowhile/for
if(SgNodeHelper::isLoopCond(condition)) {
SgNode* loopBody=SgNodeHelper::getLoopBody(stmt);
cerr<<"DEBUG: loopBody:"<<loopBody->class_name()<<endl;
LabelSet loopBodyInitLabels=setOfInitialLabelsOfStmtsInBlock(loopBody);
targetLabels=loopBodyInitLabels;
}
// if
if(isSgIfStmt(stmt)) {
SgNode* trueBranch=SgNodeHelper::getTrueBranch(stmt);
LabelSet trueBranchInitLabels=setOfInitialLabelsOfStmtsInBlock(trueBranch);
SgNode* falseBranch=SgNodeHelper::getFalseBranch(stmt);
LabelSet falseBranchInitLabels=setOfInitialLabelsOfStmtsInBlock(falseBranch);
targetLabels=trueBranchInitLabels+falseBranchInitLabels;
}
for(LabelSet::iterator j=targetLabels.begin();j!=targetLabels.end();++j) {
controlDependenceEdges.insert(Edge(*i,EDGE_FORWARD,*j));
}
}
return controlDependenceEdges;
}
示例4: sourceLabels
LabelSet Flow::sourceLabels() {
LabelSet s;
for(Flow::iterator i=begin();i!=end();++i) {
Edge e=*i;
s.insert(e.source);
}
return s;
}
示例5: targetLabels
LabelSet Flow::targetLabels() {
LabelSet s;
for(Flow::iterator i=begin();i!=end();++i) {
Edge e=*i;
s.insert(e.target);
}
return s;
}
示例6: labelSetOfIoOperations
LabelSet TransitionGraph::labelSetOfIoOperations(InputOutput::OpType op) {
LabelSet lset;
// the target node records the effect of the edge-operation on the source node.
for(TransitionGraph::iterator i=begin(); i!=end(); ++i) {
if((*i)->target->io.op==op) {
lset.insert((*i)->source->label());
}
}
return lset;
}
示例7: functionEntryLabels
LabelSet CFAnalysis::functionEntryLabels(Flow& flow) {
LabelSet resultSet;
LabelSet nodeLabels;
nodeLabels=flow.nodeLabels();
for(LabelSet::iterator i=nodeLabels.begin();i!=nodeLabels.end();++i) {
if(labeler->isFunctionEntryLabel(*i))
resultSet.insert(*i);
}
return resultSet;
}
示例8: get_labelset
static void get_labelset(BindingsPtr bindings, NodePtr root, LabelSet& labels) {
assert(root->get_op() == Op::cfg_edge_condition);
if (root->size() == 2) {
get_labelset(bindings, root->get_operand(0), labels);
root = root->get_operand(1);
}
std::string label = root->get_operand(0)->get_token().get_text();
std::size_t index = label_by_name(bindings, label);
if (index >= labels.size()) {
labels.resize(index + 1);
}
labels.set(index);
}
示例9: setOfInitialLabelsOfStmtsInBlock
LabelSet CFAnalysis::setOfInitialLabelsOfStmtsInBlock(SgNode* node) {
LabelSet ls;
if(node==0)
return ls;
if(!isSgStatement(node)) {
cerr<<"ERROR: "<<node->class_name()<<endl;
}
size_t len=node->get_numberOfTraversalSuccessors();
for(size_t i=0;i<len;++i) {
SgNode* childNode=node->get_traversalSuccessorByIndex(i);
ls.insert(initialLabel(childNode));
}
return ls;
}
示例10: Train
void Train(const std::string& dataset, const std::string& model) {
NGramMaker ngram;
LabelSet ls;
Document doc = Parse(dataset, ngram, ls);
SequenceTaggerParams tagger(ngram.dict().size(), ls.size());
std::cout << tagger.Train(doc) << "% accuracy FINAL" << std::endl;
std::ofstream out(model);
out << ngram.Serialize();
out << ls.Serialize();
out << tagger.Serialize();
InteractiveShell(tagger, ngram, ls);
}
示例11: m_LookupTable
mitk::LabelSet::LabelSet(const LabelSet &other)
: itk::Object(),
m_LookupTable(other.GetLookupTable()->Clone()),
m_ActiveLabelValue(other.GetActiveLabel()->GetValue()),
m_Layer(other.GetLayer())
{
// clone Labels
auto otherIt = other.IteratorConstBegin();
for (; otherIt != other.IteratorConstEnd(); ++otherIt)
{
m_LabelContainer[otherIt->first] = otherIt->second->Clone();
itk::SimpleMemberCommand<LabelSet>::Pointer command = itk::SimpleMemberCommand<LabelSet>::New();
command->SetCallbackFunction(this, &LabelSet::OnLabelModified);
m_LabelContainer[otherIt->first]->AddObserver(itk::ModifiedEvent(), command);
}
}
示例12: assert
//-------------------------------------------------------------------------
bool LabelSet::operator==(const LabelSet& s)
{
if (_beginVect != s._beginVect || _endVect != s._endVect)
return false;
assert(_nameVect.size() == s._nameVect.size());
for (unsigned long i=0; i<_nameVect.size(); i++)
{
if (getName(i) != s.getName(i))
return false;
}
return true;
}
示例13: InteractiveShell
void InteractiveShell(SequenceTaggerParams& tagger, NGramMaker& ngram, LabelSet& ls) {
char* line;
while ((line = readline("> "))) {
add_history(line);
std::vector<WordFeatures> toks = Tokenizer::FR(std::string(line));
if (toks.empty()) {
continue;
}
ngram.Annotate(toks);
tagger.Compute(toks);
for (auto& w : toks) {
std::cout << w.str << ": " << ls.GetString(w.pos) << "\n";
}
}
}
示例14: reachableNodesButNotBeyondTargetNode
// MS: will possibly be replaced with an implementation from the BOOST graph library
LabelSet Flow::reachableNodesButNotBeyondTargetNode(Label start, Label target) {
LabelSet reachableNodes;
LabelSet toVisitSet=succ(start);
size_t oldSize=0;
size_t newSize=0;
do {
LabelSet newToVisitSet;
for(LabelSet::iterator i=toVisitSet.begin();i!=toVisitSet.end();++i) {
LabelSet succSet=succ(*i);
for(LabelSet::iterator j=succSet.begin();j!=succSet.end();++j) {
if(reachableNodes.find(*j)==reachableNodes.end())
newToVisitSet.insert(*j);
}
}
toVisitSet=newToVisitSet;
oldSize=reachableNodes.size();
reachableNodes+=toVisitSet;
newSize=reachableNodes.size();
} while(oldSize!=newSize);
return reachableNodes;
}
示例15: Parse
Document Parse(const std::string& str, NGramMaker& ngram, LabelSet& ls) {
std::ifstream dataset(str);
std::string word;
std::string pos;
std::string line;
Document doc;
while (std::getline(dataset, line)) {
std::istringstream l(line);
std::vector<WordFeatures> toks;
l >> word;
l >> pos;
while (l) {
toks.emplace_back(word);
toks.back().pos = ls.GetLabel(pos);
l >> word;
l >> pos;
}
ngram.Learn(toks);
doc.examples.push_back(TrainingExample{toks, 0});
}
return doc;
}