void printmultimap1(multimap <string, string> &authors) { typedef multimap <string, string>::iterator iters; iters iterb = authors.lower_bound("Barth, John");//指向关键字的第一个数据 iters itere = authors.upper_bound("Barth, John");//最后一个的下一个数据 while (iterb!=itere) { cout << iterb->first << "--->" << iterb->second << endl; ++iterb; } }
vector<string> TelephoneDirectory::find_entries(int number) { multimap<int, string>::iterator lower = inverse_database.lower_bound(number); multimap<int, string>::iterator upper = inverse_database.upper_bound(number); vector<string> result; for (multimap<int, string>::iterator pos = lower; pos != upper; pos++) result.push_back(pos->second); return result; }
bool AlreadyHave(multimap<string, string> &mulMap, const pair<string, string> &searchItem) { multimap<string, string>::iterator begin = mulMap.lower_bound(searchItem.first); multimap<string, string>::iterator end = mulMap.upper_bound(searchItem.first); while(begin != end){ // cout<<begin->second<<begin->first; if(begin->second == searchItem.second) return true; ++begin; } return false; }
void traceback(int key){ multimap<int,int>::iterator first,last; printf("%d", key); first = edge.lower_bound(key); last = edge.upper_bound(key); for(;first != last; first++){ printf(" ("); traceback(first->second); printf(")"); } }
void CfgToDotImpl::processNodes(SgNode* top) { if (nodesPrinted.find(top) != nodesPrinted.end()) return; nodesPrinted.insert(top); o << "subgraph cluster_" << uintptr_t(top) << " {" << endl; o << "style=invis;" << endl; for (multimap<SgNode*, CFGNode>::const_iterator it = exploredNodes.lower_bound(top); it != exploredNodes.upper_bound(top); ++it) { printNodePlusEdges(o, it->second); } vector<SgNode*> children = top->get_traversalSuccessorContainer(); for (unsigned int i = 0; i < children.size(); ++i) { if (children[i]) { processNodes(children[i]); } } o << "}" << endl; }
static CRF_State crfstate(const vector<Token> &vt, int i) { CRF_State sample; string str = vt[i].str; // string str = normalize(vt[i].str); sample.label = vt[i].pos; sample.add_feature("W0_" + vt[i].str); sample.add_feature("NW0_" + normalize(str)); string prestr = "BOS"; if (i > 0) prestr = vt[i-1].str; // if (i > 0) prestr = normalize(vt[i-1].str); string prestr2 = "BOS"; if (i > 1) prestr2 = vt[i-2].str; // if (i > 1) prestr2 = normalize(vt[i-2].str); string poststr = "EOS"; if (i < (int)vt.size()-1) poststr = vt[i+1].str; // if (i < (int)vt.size()-1) poststr = normalize(vt[i+1].str); string poststr2 = "EOS"; if (i < (int)vt.size()-2) poststr2 = vt[i+2].str; // if (i < (int)vt.size()-2) poststr2 = normalize(vt[i+2].str); sample.add_feature("W-1_" + prestr); sample.add_feature("W+1_" + poststr); sample.add_feature("W-2_" + prestr2); sample.add_feature("W+2_" + poststr2); sample.add_feature("W-10_" + prestr + "_" + str); sample.add_feature("W0+1_" + str + "_" + poststr); sample.add_feature("W-1+1_" + prestr + "_" + poststr); //sample.add_feature("W-10+1_" + prestr + "_" + str + "_" + poststr); // sample.add_feature("W-2-1_" + prestr2 + "_" + prestr); // sample.add_feature("W+1+2_" + poststr + "_" + poststr2); // train = 10000 no effect // if (i > 0 && prestr.size() >= 3) // sample.add_feature("W-1S_" + prestr.substr(prestr.size()-3)); // if (i < (int)vt.size()-1 && poststr.size() >= 3) // sample.add_feature("W+1S_" + poststr.substr(poststr.size()-3)); // sentence type // sample.add_feature("ST_" + vt[vt.size()-1].str); for (size_t j = 1; j <= 10; j++) { char buf[1000]; // if (str.size() > j+1) { if (str.size() >= j) { sprintf(buf, "SUF%d_%s", (int)j, str.substr(str.size() - j).c_str()); sample.add_feature(buf); } // if (str.size() > j+1) { if (str.size() >= j) { sprintf(buf, "PRE%d_%s", (int)j, str.substr(0, j).c_str()); sample.add_feature(buf); } } for (size_t j = 0; j < str.size(); j++) { if (isdigit(str[j])) { sample.add_feature("CTN_NUM"); break; } } for (size_t j = 0; j < str.size(); j++) { if (isupper(str[j])) { sample.add_feature("CTN_UPP"); break; } } for (size_t j = 0; j < str.size(); j++) { if (str[j] == '-') { sample.add_feature("CTN_HPN"); break; } } bool allupper = true; for (size_t j = 0; j < str.size(); j++) { if (!isupper(str[j])) { allupper = false; break; } } if (allupper) sample.add_feature("ALL_UPP"); if (WNdic.size() > 0) { const string n = normalize(str); for (map<string, string>::const_iterator i = WNdic.lower_bound(n); i != WNdic.upper_bound(n); i++) { sample.add_feature("WN_" + i->second); } } // for (int j = 0; j < vt.size(); j++) // cout << vt[j].str << " "; // cout << endl; // cout << i << endl; // cout << sample.label << "\t"; // for (vector<string>::const_iterator j = sample.features.begin(); j != sample.features.end(); j++) { // cout << *j << " "; // } // cout << endl; return sample; }