Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

void Impala::Application::Util::DoScoreConcepts (  ) 

Definition at line 940 of file mainUtil.cpp.

References Impala::Core::Table::AveragePrecision(), Impala::Core::Table::AveragePrecisionJudged(), Impala::Util::DatabaseReadStrings(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get1(), Impala::CmdOptions::GetArg(), Impala::Util::Database::GetFilePath(), Impala::CmdOptions::GetInstance(), Impala::CmdOptions::GetNrArg(), ILOG_ERROR, ILOG_VAR, Impala::Core::Table::SimilarityTableSet::MakeFromFile(), Impala::Core::Database::MakeRawDataSet(), Impala::MakeString(), and Impala::QuidClass().

Referenced by mainUtil().

00941 {
00942 #ifndef REPOSITORY_TODO
00943     typedef Core::Database::RawDataSet RawDataSet;
00944     typedef Core::Table::SimilarityTableSet SimilarityTableSet;
00945     typedef Core::Table::AnnotationTable AnnotationTable;
00946     using Impala::Core::Table::AveragePrecision;
00947 
00948     ILOG_VAR(Impala.Application.Util.DoScoreConcept);
00949     CmdOptions& options = CmdOptions::GetInstance();
00950     if (options.GetNrArg() < 4)
00951     {
00952         ILOG_ERROR("Need more parameters");
00953         return;
00954     }
00955     String dataSetName = options.GetArg(1);
00956     String annoSet = options.GetArg(2);
00957     String namesPath = options.GetArg(3);
00958     String mappingName;
00959     if (options.GetNrArg() > 4)
00960         mappingName = options.GetArg(4);
00961 
00962     RawDataSet* dataSet = Core::Database::MakeRawDataSet(dataSetName);
00963     Impala::Util::Database* db = dataSet->GetDatabase();
00964     SimilarityTableSet* simSet =
00965         Core::Table::SimilarityTableSet::MakeFromFile(
00966                      db->GetFilePath(".", namesPath, false, false), db);
00967 
00968     Impala::Util::SimpleMap<String, String> conceptMapping;
00969     if (!mappingName.empty())
00970     {
00971         std::vector<String> lines;
00972         Impala::Util::DatabaseReadStrings(lines, mappingName, db);
00973         for (int i=0 ; i<lines.size() ; i++)
00974         {
00975             Impala::Util::StringParser p(lines[i]);
00976             String src = p.GetString(' ');
00977             String dst = p.GetString(' ', false);
00978             std::cout << src << " => " << dst << std::endl;
00979             conceptMapping.Add(src, dst);
00980         }
00981     }
00982 
00983     Core::Table::QuidTable* qTable = simSet->GetQuidTable();
00984     int qClass = QuidClass(qTable->Get1(0));
00985     Real64 map = 0;
00986     Real64 mapJ = 0;
00987     Real64 map2000 = 0;
00988     Real64 map2000J = 0;
00989     bool do2000 = (simSet->TableSize() > 2000);
00990     int nrMap = 0;
00991     std::cout << namesPath << ", size = " << simSet->TableSize() << std::endl;
00992     for (int c=0 ; c<simSet->NrTables() ; c++)
00993     {
00994         String concept = simSet->GetName(c);
00995         String mappedConcept;
00996         if (!mappingName.empty())
00997         {
00998             if (conceptMapping.Get(concept, mappedConcept))
00999             {
01000                 concept = mappedConcept;
01001             }
01002             else
01003             {
01004                 continue;
01005             }
01006         }
01007         String fName = dataSet->GetFilePathAnnotation(qClass, annoSet,
01008                                                       concept + ".tab",
01009                                                       false, false);
01010         if (fName.empty())
01011         {
01012             ILOG_ERROR("No groundtruth for " << concept);
01013             continue;
01014         }
01015         AnnotationTable* truth = AnnotationTable::MakeFromFile(concept, fName,
01016                                                                db);
01017         truth->UpdateQuidMap();
01018         Real64 ap = AveragePrecision(simSet->GetRankTable(c), truth, -1);
01019         Real64 apJ = AveragePrecisionJudged(simSet->GetRankTable(c), truth,
01020                                             false, -1);
01021         map += ap;
01022         mapJ += apJ;
01023         std::cout << MakeString(concept, 30)
01024                   << " " << ap << "\t j: " << apJ;
01025 
01026         if (do2000)
01027         {
01028             Real64 ap2000 = AveragePrecision(simSet->GetRankTable(c), truth,
01029                                              2000);
01030             Real64 ap2000J = AveragePrecisionJudged(simSet->GetRankTable(c),
01031                                                     truth, false, 2000);
01032             map2000 += ap2000;
01033             map2000J += ap2000J;
01034             std::cout << "\t " << ap2000 << "\t j: " << ap2000J;
01035         }
01036 
01037         std::cout << std::endl;
01038         nrMap++;
01039         delete truth;
01040     }
01041     std::cout << "map=" << map/nrMap << ", mapJudged=" << mapJ/nrMap;
01042     if (do2000)
01043         std::cout << " map2000=" << map2000/nrMap << ", map2000Judged="
01044                   << map2000J/nrMap;
01045     std::cout << std::endl << std::endl;
01046     delete simSet;
01047     delete dataSet;
01048 #endif
01049 }

Here is the call graph for this function:


Generated on Fri Mar 19 10:52:10 2010 for ImpalaSrc by  doxygen 1.5.1