Definition at line 53 of file mainConceptLearnClient.cpp. References ILOG_DEBUG, ILOG_ERROR, ILOG_INFO, mALE, ParseQuid(), and Impala::Timer::SplitTime(). Referenced by ConceptLearnClient(). 00054 { 00055 Timer tim; 00056 int ctim = tim.SplitTime(); 00057 int manReset; 00058 00059 manReset = 1; 00060 00061 bool done = false; 00062 00063 while (!done) 00064 { 00065 // load stage or print stage? 00066 if (!mALE->RequestSubmitted()) 00067 { 00068 ILOG_INFO("Sending data to ALE..."); 00069 // load stage: 00070 00071 mALE->PrepRequest(); 00072 00073 // read positive keyframes from file: 00074 00075 std::ifstream f("quids_positive.txt"); 00076 while (! f.eof() ) 00077 { 00078 std::string line; 00079 f >> line; 00080 if (line == "") break; 00081 Quid q = ParseQuid(line); 00082 if (q<0) { 00083 continue; 00084 } 00085 00086 ILOG_DEBUG("Positive:" << QuidObj(q)); 00087 mALE->AddPositive(q); 00088 } 00089 f.close(); 00090 00091 00092 // read negatives: 00093 00094 std::ifstream fneg("quids_negative.txt"); 00095 while (! fneg.eof() ) 00096 { 00097 std::string line; 00098 fneg >> line; 00099 if (line == "") break; 00100 Quid q = ParseQuid(line); 00101 if (q<0) { 00102 continue; 00103 } 00104 ILOG_DEBUG("Negative:" << QuidObj(q)); 00105 mALE->AddNegative(q); 00106 } 00107 fneg.close(); 00108 00109 if (!mALE->Ready()) 00110 { 00111 ILOG_ERROR("ALE not ready. Aborting."); 00112 return; 00113 } 00114 00115 // submit request: 00116 mALE->SubmitRequest(); 00117 // .. and wait! 00118 00119 while (ctim+4 > tim.SplitTime()); 00120 ctim = tim.SplitTime(); 00121 00122 } else { 00123 if (mALE->HasResults()) 00124 { 00125 // retrieve sage: 00126 ILOG_INFO("Receiving data..."); 00127 std::list<Core::Trec::QuidResult> quids = mALE->RetrieveResults(); 00128 00129 if (quids.size() > 0 && mALE->GetErrCount() < 200) 00130 { 00131 std::ostringstream b; 00132 b << "result.txt"; 00133 std::string ofname = b.str(); 00134 std::ofstream out(ofname.c_str(), std::ios::out); 00135 std::list<Core::Trec::QuidResult>::iterator i = quids.begin(); 00136 while (i != quids.end()) 00137 { 00138 out << "001 Q0 " << QuidObj(i->quid) << " " << i->rank << " " << i->score << std::endl; 00139 //out << "0" << topic << " Q0 " << shotname << " " << i->rank << " " << i->score << std::endl; 00140 i++; 00141 } 00142 out.close(); 00143 manReset = 1; 00144 } else { 00145 ILOG_INFO("Results not yet valid, retrying..."); 00146 // wait a while... 00147 while (ctim+3 > tim.SplitTime()); 00148 ctim = tim.SplitTime(); 00149 } 00150 00151 manReset++; 00152 if (manReset >3) 00153 { 00154 ILOG_ERROR("We have waited too long, resetting..."); 00155 mALE->PrepareNewID(); 00156 manReset = 1; 00157 } /*else 00158 { 00159 ILOG_ERROR("FAILURE: could not find results for this set."); 00160 done = true; 00161 } */ 00162 } else { 00163 // no results yet, wait some more. 00164 while (ctim+3 > tim.SplitTime()); 00165 ctim = tim.SplitTime(); 00166 } 00167 } 00168 00169 } 00170 00171 }
Here is the call graph for this function:
|