/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott * LOJJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott * result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, "http://www.lightoj.com/volume_usersubmissions.php"); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first row if (!RE2::PartialMatch(html, "(?s)(<tr class=\"newone\">.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch(status, "(?s)sub_id=([0-9]*).*?<div.*?>(.*?)</div>", &runid, &result)) { throw Exception("Failed to get current result."); } result = trim(result); if (isFinalResult(result)) { // result is the final one result = convertResult(result); if (result != "Compile Error") { // no details for CE results if (!RE2::PartialMatch( status, "(?s)sub_id=([0-9]*).*?<td.*?<td.*?<td.*?<td.*?>(.*?)</td" ".*?<td.*?>(.*?)</td>", &runid, &time_used, &memory_used)) { throw Exception("Failed to parse details from status row."); } int time_ms = stringToDouble(time_used) * 1000 + 0.001; time_used = intToString(time_ms); } else { memory_used = time_used = "0"; } result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(result); result_bott->Settime_used(stringToInt(time_used)); result_bott->Setmemory_used(stringToInt(memory_used)); result_bott->Setremote_runid(trim(runid)); break; } } return result_bott; }
bool getStatus(string pid,string lang,string & result,string& ce_info,string &tu,string &mu) { int begin=time(NULL); string runid; tu=mu="0"; string ts; while (true) { FILE * fp=fopen(tfilename,"w+"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "loj.cookie"); string url=(string)"http://www.lightoj.com/volume_usersubmissions.php"; //cout<<url; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; ts=getResFromFile(tfilename); if (ts=="") return false; writelog((char *)ts.c_str()); runid=getRunid(ts); result=getResult(ts); //cout << result; if (result.find("Not")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos ) { break; } if (time(NULL)-begin>MAX_WAIT_TIME) break; } if (!(result.find("Not")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos)) return false; //cout<<runid<<" "<<tu<<" "<<mu<<" "<<result<<endl; if (result=="Compilation Error") ce_info=getCEinfo(runid); else { tu=getUsedTime(ts); mu=getUsedMem(ts); ce_info=""; } //cout<<ce_info; if (result!="Accepted"&&result[result.length()-1]=='d') { result.erase(result.end()-2,result.end()); } result=convertResult(result); return true; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott *SCUJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott *result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception ("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, ("http://cstest.scu.edu.cn/soj/solutions.action?userId=" + escapeURL(info->GetUsername()) + "&problemId=" + bott->Getvid()).c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first row if (!RE2::PartialMatch(html, "(?s).*<table.*?<tr.*?(<tr.*?<td height=\"44\">.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch(status, "(?s)<td.*?>([0-9]*).*?<font.*?>(.*)</font>", &runid, &result)) { throw Exception("Failed to get current result."); } result = trim(result); if (isFinalResult(result)) { // result is the final one result = convertResult(result); if (!RE2::PartialMatch(status, "(?s)<td.*?>([0-9]*).*?<font.*?>.*</font>.*?<td>(.*?)</td>.*?<td>(.*?)</td>", &runid, &time_used, &memory_used)) { throw Exception ("Failed to parse details from status row."); } result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(result); result_bott->Settime_used(trim(time_used)); result_bott->Setmemory_used(trim(memory_used)); result_bott->Setremote_runid(trim(runid)); break; } } return result_bott; }
bool getStatus(string pid,string lang,string & result,string& ce_info,string &tu,string &mu) { usleep(600000); int begin=time(NULL); string runid; tu=mu="0"; string ts; while (true) { FILE * fp=fopen(tfilename,"w+"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "sgu.cookie"); string url=(string)"http://acm.sgu.ru/status.php?id="+username+"&idmode=1&problem="+pid; //cout<<url; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; ts=getResFromFile(tfilename); if (ts=="") return false; //cout<<ts; runid=getRunid(ts); result=getResult(ts); //cout << result; if (result.find("queue")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Waiting")==string::npos &&result.find("Compiling")==string::npos &&result.length()>4) { break; } if (time(NULL)-begin>MAX_WAIT_TIME) break; } if (!(result.find("queue")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Waiting")==string::npos &&result.find("Compiling")==string::npos &&result.length()>4)) return false; tu=getUsedTime(ts); mu=getUsedMem(ts); //cout<<runid<<" "<<tu<<" "<<mu<<" "<<result<<endl; result=convertResult(result); if (result=="Compile Error") ce_info=getCEinfo(runid); else ce_info=""; //cout<<ce_info; return true; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott * HRBUSTJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott * result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt( curl, CURLOPT_URL, ((string) "http://acm.hrbust.edu.cn/index.php?m=Status&a=" "showStatus&problem_id=" + escapeURL(bott->Getvid()) + "&user_name=" + escapeURL(info->GetUsername()) + "&language=" + convertLanguage(bott->Getlanguage())).c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first row if (html.find("var is_login=\"\";") != string::npos || !RE2::PartialMatch(html, "(?s)<table class=\"ojlist\".*?<tr.*?(<tr.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch(status, "(?s)<td.*?<td>([0-9]*).*?<td.*?<td.*?>(.*?)</td>", &runid, &result)) { throw Exception("Failed to get current result."); } result = convertResult(trim(result)); if (isFinalResult(result)) { // result is the final one if (!RE2::PartialMatch(status, "(?s)>([0-9]*)ms.*?>([0-9]*)k", &time_used, &memory_used)) { throw Exception("Failed to parse details from status row."); } result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(result); result_bott->Settime_used(stringToInt(time_used)); result_bott->Setmemory_used(stringToInt(memory_used)); result_bott->Setremote_runid(trim(runid)); break; } } return result_bott; }
void HRBUSTJudger::getStatus() { // prepareCurl(); while (true) { stringstream sStream; string lang, outer_oj_id; char *lang_tmp, *outer_oj_id_tmp; sStream << judgeInfo.getLang(); sStream >> lang; sStream << judgeInfo.getId(); sStream >> outer_oj_id; string res_url = "http://acm.hrbust.edu.cn/index.php?m=Status&a=showStatus&problem_id=" + outer_oj_id + "&user_name=acmstep&language=" + lang; curl_easy_setopt(easy_handle, CURLOPT_URL, res_url.c_str()); cout << "Before performCurl()................." << endl; performCurl("tmpfiles/statusdata.html"); cout << "After performCurl()................." << endl; string res, runid, result, time_used, memory_used; string html = fileToString("tmpfiles/statusdata.html"); if (code != CURLE_OK) syslog(LOG_ERR, "getStatus failed."); else { if (html.find("var is_login=\"\";") != string::npos || !RE2::PartialMatch(html, "(?s)<table class=\"ojlist\".*?<tr.*?(<tr.*?</tr>)", &res)) { syslog(LOG_ERR, "[ERROR] HRBUSTJudger: Failed to get status row."); } if (!RE2::PartialMatch(res, "(?s)<td.*?<td>([0-9]*).*?<td.*?<td.*?>(.*?)</td>", &runid, &result)) { syslog(LOG_ERR, "[ERROR] HRBUSTJudger: Fail to get current result."); } result = convertResult(trim(result)); cout << "Result is: " << result << endl; if (isFinalResult(result)) { if (!RE2::PartialMatch(res, "(?s)>([0-9]*)ms.*?>([0-9]*)k", &time_used, &memory_used)) { syslog(LOG_ERR, "[ERROR] HRBUSTJudger: Failed to parse details from status row."); } cout << "0---------------------------------" << endl; cout << "Time used: " << time_used << " Memory_used: " << memory_used<< endl; judgeResult.setCodeId(judgeInfo.getCodeId()); judgeResult.setRunId(atoi(trim(runid).c_str())); judgeResult.setJudgeStatus(status_table[result]); judgeResult.setRunTime(atoi(trim(time_used).c_str())); judgeResult.setRunMemory(atoi(trim(memory_used).c_str())); cout << "[Result] Get JudgeStatus: " << judgeResult.getJudgeStatus() << endl; if (judgeResult.getJudgeStatus() == OJ_CE) { judgeResult.setErrorInfo(getCEinfo()); } else { judgeResult.setErrorInfo("NULL"); } break; } else { usleep(5000); } } } }
//http://acm.fzu.edu.cn/log.php?pid=1000&user=bnuvjudge&language=1 bool getStatus(string pid,string lang,string & result,string& ce_info,string &tu,string &mu) { int begin=time(NULL); string runid; tu=mu="0"; string ts; while (true) { FILE * fp=fopen(tfilename,"w+"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "fzu.cookie"); string url=(string)"http://acm.fzu.edu.cn/log.php?user="******"&pid="+pid; //cout<<url<<endl; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; ts=getResFromFile(tfilename); //cout<<ts; if (ts.find("Error Occurred")!=string::npos||ts.find("The page is temporarily unavailable")!=string::npos) return false; runid=getRunid(ts); result=getResult(ts); //cout << result; if (result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos) { break; } if (time(NULL)-begin>MAX_WAIT_TIME) break; } if (!(result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos)) return false; result=convertResult(result); if (result=="Compile Error") ce_info=getCEinfo(runid); else ce_info=""; if (result=="Accepted") { tu=getUsedTime(ts); mu=getUsedMem(ts); } return true; }
//http://acm.nbut.cn/Problem/status.xhtml?username=bnuvjudge&problemid=1000&language=1 bool getStatus(string pid,string lang,string & result,string& ce_info,string &tu,string &mu) { int begin=time(NULL); string runid; tu=mu="0"; string ts; while (true) { FILE * fp=fopen(tfilename,"w+"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "nbut.cookie"); string url=(string)"http://acm.nbut.cn/Problem/status.xhtml?username="******"&problemid="+pid+"&language="+lang; //cout<<url<<endl; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; ts=getResFromFile(tfilename); //cout<<ts; if (ts.find("Error Occurred")!=string::npos||ts.find("The page is temporarily unavailable")!=string::npos) return false; runid=getRunid(ts); result=getResult(ts); //cout << result; if (result.find("WAITING")==string::npos &&result.find("RUNNING")==string::npos &&result.find("JUDGING")==string::npos &&result.find("QUEUING")==string::npos &&result.find("COMPILING")==string::npos) { break; } if (time(NULL)-begin>MAX_WAIT_TIME) break; } if (!(result.find("WAITING")==string::npos &&result.find("RUNNING")==string::npos &&result.find("JUDGING")==string::npos &&result.find("QUEUING")==string::npos &&result.find("COMPILING")==string::npos)) return false; result=convertResult(result); if (result=="Compile Error") ce_info=getCEinfo(runid); else ce_info=""; tu=getUsedTime(ts); mu=getUsedMem(ts); return true; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott *CCJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott *result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception ("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, ((string) "http://www.codechef.com/get_submission_status/" + bott-> Getremote_runid()).c_str ()); performCurl(); string html = loadAllFromFile(tmpfilename); string result, time_used, memory_used; // get result if (!RE2::PartialMatch (html, "\"result_code\":\"(.*?)\"", &result)) { throw Exception("Failed to get current result."); } result = convertResult(result); if (isFinalResult(result)) { // if result if final, get details if (!RE2::PartialMatch(html, "(?s)\"time\":\"(.*?)\"", &time_used)) { throw Exception ("Failed to parse details from status row."); } int time_ms = stringToDouble(time_used) * 1000 + 0.001; int memory_kb; result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(result); result_bott->Settime_used(intToString(time_ms)); if (result != "Compile Error") { // CodeChef will update Memory usage later in submission table // Weird... why don't they put in get_submission_status api... memory_used = "0"; prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, ((string) "http://www.codechef.com/submissions?handle=" + escapeURL (info-> GetUsername ()) + "&pcode=" + escapeURL (bott->Getvid ())). c_str()); performCurl(); html = loadAllFromFile(tmpfilename); string status; if (!RE2::PartialMatch(html, "(?s)(<tr class=\"kol.*?<td width=\"60\">" + bott->Getremote_runid() + "</td>.*?</tr>)", &status)) { // Status row is not updated in time... log("Memory data not ready yet... Never mind, use 0 instead."); memory_used = "0"; } else if (!RE2::PartialMatch (status, ">([0-9\\.]*)M", &memory_used)) { memory_used = "0"; } memory_kb = stringToDouble(memory_used) * 1024 + 0.001; } result_bott->Setmemory_used(intToString(memory_kb)); result_bott->Setremote_runid(bott->Getremote_runid()); break; } } return result_bott; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott * ZJUJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott * result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt( curl, CURLOPT_URL, ((string) "http://acm.zju.edu.cn/onlinejudge/showRuns.do?" "contestId=1&idStart=" + bott->Getremote_runid() + "&idEnd=" + bott->Getremote_runid()).c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string result, time_used, memory_used; // get first row if (!RE2::PartialMatch(html, "(?s)(<tr class=\"rowOdd\">.*?</tr>)", &status)) { continue; } // get result if (!RE2::PartialMatch( status, "(?s)<td class=\"runJudgeStatus\".*?<span.*?>(.*?)</span>", &result)) { throw Exception("Failed to get current result."); } result = trim(result); if (isFinalResult(result)) { // result is the final one result = convertResult(result); if (!RE2::PartialMatch( status, "(?s)<td class=\"runTime\".*?>(.*?)</td>.*" "<td class=\"runMemory\".*?>(.*?)</td>", &time_used, &memory_used)) { throw Exception("Failed to parse details from status row."); } result_bott = new Bott; result_bott->Setremote_runid(bott->Getremote_runid()); result_bott->Settype(RESULT_REPORT); result_bott->Setresult(result); result_bott->Settime_used(stringToInt(time_used)); result_bott->Setmemory_used(stringToInt(memory_used)); if (result == "Compile Error") { // hack for ZJU, don't know why its submission id is inconsistent with // judge protocol if (!RE2::PartialMatch( status, "(?s)showJudgeComment\\.do\\?submissionId=([0-9]*)", &submission_id_for_ce)) { submission_id_for_ce = bott->Getremote_runid(); } } break; } } return result_bott; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott *NJUPTJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott *result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception ("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, ((string) "http://acm.njupt.edu.cn/acmhome/showstatus.do"). c_str()); string post = (string) "problemId=" + bott->Getvid() + "&languageS=" + escapeURL(bott->Getlanguage()) + "&userName="******"&resultS=All"; curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first row if (!RE2::PartialMatch (html, "(?s)<table.*?</thead>.*?(<tr.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch(status, "(?s)method=showdetail.*?value=\"(.*?)\".*?<b acc=\"acc\"></b>\\s*(.*?)\\s*<b acc=\"acc\"></b>", &runid, &result)) { throw Exception("Failed to get current result."); } result = convertResult(trim(result)); if (isFinalResult(result)) { // result is the final one, get details if (result == "Accepted") { // only accepted run has details if (!RE2::PartialMatch(status, "(?s)([0-9]*)<b ms=\"ms\"></b>MS.*?([0-9]*)<b k=\"k\"></b>K", &time_used, &memory_used)) { throw Exception ("Failed to parse details from status row."); } } else { memory_used = time_used = "0"; } result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(convertResult(result)); result_bott->Settime_used(trim(time_used)); result_bott->Setmemory_used(trim(memory_used)); result_bott->Setremote_runid(trim(runid)); break; } } return result_bott; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott * SPOJJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott * result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, ("http://www.spoj.com/status/" + info->GetUsername() + "/ajax=1").c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first row if (!RE2::PartialMatch(html, "(?s)(<tr class=\"kol.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch(status, "(?s)statusres_([0-9]*).*?>\\w*(?:<.*?>)?(.*?)\\w*<span", &runid, &result)) { throw Exception("Failed to get current result."); } result = trim(result); if (isFinalResult(result)) { // result is the final one result = convertResult(result); if (result == "Accepted" || result == "Runtime Error" || result == "Wrong Answer") { // only have details for these three results string unit; if (!RE2::PartialMatch( status, "(?s)statustime_.*?<a.*?>(.*?)</a>.*?statusmem_.*?>\\s*(.*?)(M|k)", &time_used, &memory_used, &unit)) { throw Exception("Failed to parse details from status row."); } int time_ms = stringToDouble(time_used) * 1000 + 0.001; time_used = intToString(time_ms); if (unit == "M") { int memory_mb = stringToDouble(memory_used) * 1024 + 0.001; memory_used = intToString(memory_mb); } } else { time_used = memory_used = "0"; } result_bott = new Bott; result_bott->Setremote_runid(runid); result_bott->Settype(RESULT_REPORT); result_bott->Setresult(result); result_bott->Settime_used(stringToInt(time_used)); result_bott->Setmemory_used(stringToInt(memory_used)); break; } } return result_bott; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott * AizuJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott * result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt( curl, CURLOPT_URL, ((string) "http://judge.u-aizu.ac.jp/onlinejudge/status.jsp").c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first row of current user if (!RE2::PartialMatch( html, "(?s)(<tr *class=\"dat\".*?>" + info->GetUsername() + "<.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } html = status; if (!RE2::PartialMatch( html, "(?s).*(<tr *class=\"dat\".*?>" + info->GetUsername() + "<.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch( status, "(?s)rid=([0-9]*).*status.*?<a href=\"review.*?>(.*?)</a>", &runid, &result)) { throw Exception("Failed to get current result."); } result = convertResult(trim(result)); if (isFinalResult(result)) { // result is the final one, get details if (result != "Runtime Error" && result != "Compile Error") { if (!RE2::PartialMatch( status, "(?s)<td class=\"text-center\">([0-9\\.]*) s.*?<td.*?>([0-9]*) KB", &time_used, &memory_used)) { throw Exception("Failed to parse details from status row."); } } else { memory_used = time_used = "0"; } result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(convertResult(result)); result_bott->Settime_used( (int)(stringToDouble(time_used) * 100 + 0.1)); result_bott->Setmemory_used(stringToInt(memory_used)); result_bott->Setremote_runid(trim(runid)); break; } } return result_bott; }
void JuliusPlus::OnOutputResult(Recog *recog) { //juliusの結果を plus 整形済みパータンとして再構築する. std::list<OncSentence*> allSentence; convertResult(recog, &allSentence); //認識した結果を出す. std::cout << std::endl; std::cout << "==---認識結果---------------------------------------------------===" << std::endl; //何も入っていない、ゴミしかないようだったら何もしないでおしまい。 if (allSentence.empty()) { FreeAllSentenceList(&allSentence); std::cout << "//スキップします。" << std::endl; return ; } int i = 1; for(auto it = allSentence.begin() ; it != allSentence.end() ; ++it, ++i) { std::stringstream word; std::stringstream yomi; std::stringstream dictNumber; std::stringstream cmscore; std::stringstream avgscore; std::stringstream begin_frame; std::stringstream end_frame; std::stringstream plus_node_score; for( auto it2 = (*it)->nodes.begin() ; it2 != (*it)->nodes.end() ; ++it2) { word << (*it2)->wordnode->word << " "; yomi << (*it2)->wordnode->yomi << " "; dictNumber << (*it2)->dictNumber << " "; cmscore << (*it2)->cmscore << " "; avgscore << (*it2)->avgscore << " "; begin_frame << (*it2)->begin_frame << " "; end_frame << (*it2)->end_frame << " "; plus_node_score << (*it2)->plus_node_score << " "; } bool isok = false; std::cout << i << ". " << "plus_sentence_score:" << (*it)->plus_sentence_score << " score:" << (*it)->score << std::endl; if ( ! ( (*it)->plus_sentence_score >= this->BasicRuleConfidenceFilter ) ) { std::cout << " 誤認識、スコア(" << (*it)->plus_sentence_score << ")が足りない。" << this->BasicRuleConfidenceFilter << "以上が合格" << std::endl; } else { //検出した呼びかけをもう一度再検証する。 bool dictationCheck = checkDictation(recog,*it); if (!dictationCheck) { std::cout << " 誤認識、ディクテーションフィルターもどき、呼びかけチェックの結果エラー。認識単語:" << this->DictationCheckString << std::endl; } else { std::cout << " マッチ!!!!!!!!!!!!!" << std::endl; isok = true; } } std::cout << " word :" << word.str() << std::endl; std::cout << " yomi :" << yomi.str() << std::endl; std::cout << " dictNumber :" << dictNumber.str() << std::endl; std::cout << " cmsscore :" << cmscore.str() << std::endl; std::cout << " avgscore :" << avgscore.str() << std::endl; std::cout << " begin_frame:" << begin_frame.str() << std::endl; std::cout << " end_frame :" << end_frame.str() << std::endl; std::cout << " plus_node_s:" << plus_node_score.str() << std::endl; std::cout << std::endl; if ( isok ) {//マッチしているのならコールバックを読んであげよう。 if ( (*it)->nodes.size() <= 1 ) {//呼びかけ + コマンドと2つのものを見るので、それ以下の物には興味ない continue; } const CallbackDataStruct* callback = SearchCallbackWhereDICT(*it); if (callback == NULL) { std::cout << " 有効なコールバックではありません" << std::endl; } else { //本当はcapture も渡せるんだけどねー /////C++でやろうとすると 宣言がめんどいので省略するべさー /////const std::map<std::string,std::string> capture = CreateCaptureStringWhereDICT(*it); ///// callback->callbackFunctionalObject(); //ちょっと派手に改行2つも入れちゃうわー std::cout << std::endl << std::endl; } } //結果は1つだけば十分だろう・・・・ if (i >= 1) { break; } } std::cout << std::flush; FreeAllSentenceList(&allSentence); }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott * CFJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott * result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, ((string) "http://codeforces.com/submissions/" + info->GetUsername()).c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first result row if (!RE2::PartialMatch(html, "(?s)<tr.*first-row.*?(<tr.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch(status, "(?s)status-cell.*?>(.*?)</td>", &result)) { throw Exception("Failed to get current result."); } if (isFinalResult(result)) { // if result if final, get details if (!RE2::PartialMatch( status, "(?s)data-submission-id=\"([0-9]*)\".*submissionVerdict" "=\"(.*?)\".*time-consumed-cell.*?>(.*?) ms.*memory-consumed" "-cell.*?>(.*?) KB", &runid, &result, &time_used, &memory_used)) { // try api when failed log("Failed to parse details from status row, try API."); prepareCurl(); curl_easy_setopt( curl, CURLOPT_URL, ((string) "http://codeforces.com/api/user.status?handle=" + info->GetUsername() + "&from=1&count=1").c_str()); performCurl(); string json = loadAllFromFile(tmpfilename); if (!RE2::PartialMatch( json, "(?s)\"id\":([0-9]*)\"verdict\":\"(.*?)\".*\"timeConsumed" "Millis\":([0-9]*),\"memeryConsumedBytes\":([0-9]*)", &runid, &result, &time_used, &memory_used)) { throw Exception("Failed to parse details from API."); } } result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(convertResult(result)); result_bott->Settime_used(stringToInt(time_used)); result_bott->Setmemory_used(stringToInt(memory_used)); result_bott->Setremote_runid(trim(runid)); break; } } // for CodeForces, we can store extra infos in ce_info column string contest; // no need to check fail or not, since submit function has already done it RE2::PartialMatch(bott->Getvid(), "(^[0-9]{1,6})", &contest); if (result_bott->Getresult() != "Accepted" && result_bott->Getresult() != "Compile Error") { result_bott->Setce_info( getVerdict(contest, result_bott->Getremote_runid())); } return result_bott; }