本文整理汇总了C++中NameMap::SetId方法的典型用法代码示例。如果您正苦于以下问题:C++ NameMap::SetId方法的具体用法?C++ NameMap::SetId怎么用?C++ NameMap::SetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NameMap
的用法示例。
在下文中一共展示了NameMap::SetId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeRelationGraphR
RelationGraphR* MakeRelationGraphR(string &inputFile){
ifstream myfile(inputFile.c_str());
if (myfile.is_open()){
string line;
getline (myfile,line);
int numDomains = atoi(line.c_str()); //get the number of domains
getline (myfile,line);
int numContexts = atoi(line.c_str()); //get the number of contexts
if(numContexts + 1 != numDomains) {
string errMsg = "Number of domains and number of contexts are not consistent";
Error(errMsg);
}
vector<string> domainNames;
map<string,int> domainName_id_map;
map<int,int> domainId_size_map; //map domain number to number of elements
vector<NameMap*> nameMaps;
//get set names and thier name files
for(int i=0; i < numDomains; i++){
getline(myfile,line); //this is the domain name
//the line is split into name and number of elements
vector<string> tkns;
Tokenize(line, tkns, ";");
//first token is name of domain
domainNames.push_back(tkns[0]);
//second token is number of elements
domainId_size_map[i+1] = atoi(tkns[1].c_str());
domainName_id_map[tkns[0]]=i+1;
getline(myfile,line); //this is the path to the namefile
NameMap *nmp = new NameMap(line,atoi(tkns[1].c_str()));
nmp->SetId(i+1);
nameMaps.push_back(nmp);
}
//now get contexts and relation graph
RelationGraphR *grph = new RelationGraphR();
for(int i=0; i < numContexts; i++){
getline(myfile,line); //this line specifies the two domains
vector<string> currDomainNames;
string ctxName;
Tokenize(line,currDomainNames,"--");
int dId1 = domainName_id_map[currDomainNames[0]];
//check if a new element was inserted indicating an error
if(domainName_id_map.size() > numDomains) {
string errMsg = "Error specifying context..."+currDomainNames[0]+" does not match any previoulsy defined domain";
Error(errMsg);
}
int dId2 = domainName_id_map[currDomainNames[1]];
//check if a new element was inserted indicating an error
if(domainName_id_map.size() > numDomains) {
string errMsg = "Error specifying context..."+currDomainNames[1]+" does not match any previoulsy defined domain";
Error(errMsg);
}
ctxName = currDomainNames[0]+"__"+currDomainNames[1];
getline(myfile,line); //this line specifies the fimi file
grph->AddRContext(MakeRContext(line,dId1,dId2,ctxName,i+1,nameMaps[dId1-1],nameMaps[dId2-1], domainId_size_map[dId1],domainId_size_map[dId2]));
}
myfile.close();
return grph;
}
else{
string errMsg="Could not open the input file: "+inputFile;
Error(errMsg);
}
}