Definition at line 1302 of file mainUtil.cpp. References Impala::Util::SimpleMapBase< IdxT, ElemT, DelT >::Add(), Impala::Core::Table::AveragePrecision(), Impala::Core::Table::AveragePrecisionJudged(), Impala::Util::SimpleMapBase< IdxT, ElemT, DelT >::Get(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get1(), Impala::CmdOptions::GetArg(), Impala::CmdOptions::GetInstance(), Impala::CmdOptions::GetNrArg(), ILOG_ERROR, ILOG_INFO, ILOG_VAR, Impala::Core::Database::MakeRawDataSet(), Impala::MakeString(), Impala::QuidClass(), Impala::Persistency::File::ReadStrings(), and Impala::Persistency::RepositoryGetFile(). Referenced by mainUtil(). 01303 { 01304 typedef Core::Database::RawDataSet RawDataSet; 01305 typedef Core::Table::SimilarityTableSet SimilarityTableSet; 01306 typedef Core::Table::AnnotationTable AnnotationTable; 01307 using Impala::Core::Table::AveragePrecision; 01308 01309 ILOG_VAR(Impala.Application.Util.DoScoreConcept); 01310 CmdOptions& options = CmdOptions::GetInstance(); 01311 if (options.GetNrArg() < 5) 01312 { 01313 ILOG_ERROR("Need more parameters"); 01314 return; 01315 } 01316 String dataSetName = options.GetArg(1); 01317 String conceptSet = options.GetArg(2); 01318 String model = options.GetArg(3); 01319 String feature = options.GetArg(4); 01320 String annotations = conceptSet; 01321 if (options.GetNrArg() > 5) 01322 annotations = options.GetArg(5); 01323 String mappingName; 01324 if (options.GetNrArg() > 6) 01325 mappingName = options.GetArg(6); 01326 01327 RawDataSet* dataSet = Core::Database::MakeRawDataSet(dataSetName); 01328 SimilarityTableSetLocator simLoc(dataSet->GetLocator(), true, "", 01329 conceptSet, model, feature, ""); 01330 SimilarityTableSet* simSet = SimilarityTableSetRepository().Get(simLoc); 01331 Impala::Util::SimpleMap<String, String> conceptMapping; 01332 if (!mappingName.empty()) 01333 { 01334 std::vector<String> lines; 01335 Persistency::File file = RepositoryGetFile(mappingName, false, false); 01336 file.ReadStrings(lines); 01337 for (int i=0 ; i<lines.size() ; i++) 01338 { 01339 Impala::Util::StringParser p(lines[i]); 01340 String src = p.GetString(' '); 01341 String dst = p.GetString(' ', false); 01342 std::cout << src << " => " << dst << std::endl; 01343 conceptMapping.Add(src, dst); 01344 } 01345 } 01346 01347 Core::Table::QuidTable* qTable = simSet->GetQuidTable(); 01348 int qClass = QuidClass(qTable->Get1(0)); 01349 Real64 map = 0; 01350 Real64 mapJ = 0; 01351 Real64 map2000 = 0; 01352 Real64 map2000J = 0; 01353 bool do2000 = (simSet->TableSize() > 2000); 01354 int nrMap = 0; 01355 //std::cout << namesPath << ", size = " << simSet->TableSize() << std::endl; 01356 std::cout << simLoc << ", size = " << simSet->TableSize() << std::endl; 01357 for (int c=0 ; c<simSet->NrTables() ; c++) 01358 { 01359 String concept = simSet->GetName(c); 01360 String mappedConcept; 01361 if (!mappingName.empty()) 01362 { 01363 if (conceptMapping.Get(concept, mappedConcept)) 01364 { 01365 concept = mappedConcept; 01366 } 01367 else 01368 { 01369 continue; 01370 } 01371 } 01372 AnnotationTableLocator annoLoc(dataSet->GetLocator(), qClass, 01373 annotations, concept); 01374 if (!AnnotationTableRepository().Exists(annoLoc)) 01375 { 01376 ILOG_INFO("No groundtruth for " << concept); 01377 continue; 01378 } 01379 AnnotationTable* truth = AnnotationTableRepository().Get(annoLoc); 01380 truth->UpdateQuidMap(); 01381 Real64 ap = AveragePrecision(simSet->GetRankTable(c), truth, -1); 01382 Real64 apJ = AveragePrecisionJudged(simSet->GetRankTable(c), truth, 01383 false, -1); 01384 map += ap; 01385 mapJ += apJ; 01386 std::cout << MakeString(concept, 30) 01387 << " " << ap << "\t j: " << apJ; 01388 01389 if (do2000) 01390 { 01391 Real64 ap2000 = AveragePrecision(simSet->GetRankTable(c), truth, 01392 2000); 01393 Real64 ap2000J = AveragePrecisionJudged(simSet->GetRankTable(c), 01394 truth, false, 2000); 01395 map2000 += ap2000; 01396 map2000J += ap2000J; 01397 std::cout << "\t " << ap2000 << "\t j: " << ap2000J; 01398 } 01399 01400 std::cout << std::endl; 01401 nrMap++; 01402 delete truth; 01403 } 01404 std::cout << "map=" << map/nrMap << ", mapJudged=" << mapJ/nrMap; 01405 if (do2000) 01406 std::cout << " map2000=" << map2000/nrMap << ", map2000Judged=" 01407 << map2000J/nrMap; 01408 std::cout << std::endl << std::endl; 01409 delete simSet; 01410 delete dataSet; 01411 }
Here is the call graph for this function: ![]()
|