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

void Impala::Application::Table::DoImportSimilarityTableSet (  ) 

Definition at line 519 of file mainTable.cpp.

References Impala::atof(), Impala::atol(), Impala::Util::DatabaseReadString(), Impala::FileNameTail(), Impala::CmdOptions::GetArg(), Impala::Util::Database::GetInstance(), Impala::CmdOptions::GetInstance(), Impala::CmdOptions::GetNrArg(), ILOG_ERROR, ILOG_INFO, and ILOG_VAR.

Referenced by mainTable().

00520 {
00521     typedef Core::Table::SimilarityTableSet SimilarityTableSet;
00522     typedef Core::Table::SimilarityTableSet::SimTableType SimTableType;
00523 
00524     ILOG_VAR(Impala.Application.Table.DoImportSimilarityTableSet);
00525     ILOG_ERROR("Will fail because doesn't have Quids (yet)");
00526     CmdOptions& options = CmdOptions::GetInstance();
00527     if (options.GetNrArg() < 5)
00528     {
00529         ILOG_ERROR("Need more arguments");
00530         return;
00531     }
00532     String outDir = options.GetArg(1);
00533     String conceptFile = options.GetArg(2);
00534     String inDir = options.GetArg(3);
00535     int nrIds = atol(options.GetArg(4));
00536     String fileExt("");
00537     if (options.GetNrArg() > 5)
00538         fileExt = options.GetArg(5);
00539     Util::Database* db = &Util::Database::GetInstance();
00540 
00541     std::vector<String> concepts;
00542     Util::DatabaseReadString(std::back_inserter(concepts), conceptFile, db, true);
00543     ILOG_INFO("nrConcepts = " << concepts.size());
00544     SimilarityTableSet simSet(concepts, nrIds);
00545     String outPath = outDir + "/" + FileNameTail(conceptFile) + "/";
00546     simSet.SaveNames(outPath, db);
00547     for (int c=0 ; c<concepts.size() ; c++)
00548     {
00549         String fName = inDir + "/" + concepts[c] + fileExt;
00550         ILOG_INFO("importing " << concepts[c] << " from " << fName);
00551         std::vector<String> lines;
00552         Util::DatabaseReadString(std::back_inserter(lines), fName, db, true);
00553         if (lines.size() != nrIds)
00554         {
00555             ILOG_ERROR("wrong number of lines : " << lines.size() <<
00556                        " instead of " << nrIds);
00557             continue;
00558         }
00559         SimTableType* simTable = simSet.GetSimTable(c);
00560         simTable->SetSize(0);
00561         for (int i=0 ; i<lines.size() ; i++)
00562             simTable->Add(atof(lines[i]));
00563         simSet.ComputeRank(c, true);
00564         simSet.Save(c, outPath, db, true);
00565     }
00566 }

Here is the call graph for this function:


Generated on Thu Jan 13 09:16:18 2011 for ImpalaSrc by  doxygen 1.5.1