Skip to content

Commit

Permalink
Implemented writing of evaluation result in colum format to support e…
Browse files Browse the repository at this point in the history
…asy manipulation of results
  • Loading branch information
gauravaror committed Jul 28, 2012
1 parent 80eaeac commit 2c246e7
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
4 changes: 4 additions & 0 deletions config_file.cc
Expand Up @@ -99,6 +99,9 @@ void CONFIG_TREC::record_tag( string config_tag, string config_value ) {
nterms = atoi(config_value.c_str());
found = 1;
} // END if
if ( config_tag == "evaluationfiles" ) {
evaluationfiles = config_value;
} // END if

if( !found ) {
cout << "ERROR: could not locate tag [" << config_tag << "] for value [" << config_value
Expand All @@ -125,6 +128,7 @@ void CONFIG_TREC::setup_config( string filename ) {
relfile= "noneassigned"; // path/filename of relevance judgements file
runname = "xapiantrec"; // name of the run
nterms = 100; // no of terms to pick from the topic
evaluationfiles = "eval.log";

std::ifstream configfile( filename.c_str() );

Expand Down
3 changes: 2 additions & 1 deletion config_file.h
Expand Up @@ -47,6 +47,7 @@ class CONFIG_TREC {
string runname; // name of the run
int nterms; // no of terms to pick from the topic
string stopsfile; // name of the stopword file
string evaluationfiles; //path/filename of the evaluation files

// private access routines
void record_tag( string config_tag, string config_value );
Expand Down Expand Up @@ -81,7 +82,7 @@ class CONFIG_TREC {
string get_runname() { return runname; }
int get_nterms() { return nterms; }
string get_stopsfile() { return stopsfile; }

string get_evaluationsfile() { return evaluationfiles; }
}; // END class CONFIG

#endif
1 change: 0 additions & 1 deletion qrelinmemory.cc
Expand Up @@ -31,7 +31,6 @@ QRelInMemory::isRelevant(string docno) {

for (grades=relGrade.begin() ;grades != relGrade.end() ;grades++ ) {
map<int,set<string> >::iterator docs = relGradeDocMap.find(*grades);
cout<<"Grades"<<*grades<<endl;
if ( docs != relGradeDocMap.end()) {
if(docs->second.find(docno) != docs->second.end())
return true;
Expand Down
43 changes: 41 additions & 2 deletions trec_adhoceval.cc
Expand Up @@ -96,10 +96,11 @@ if (data.size() == 7) {
listofRelevantRetrieved.push_back(*relevantRetrieved);
numberofRetrievedCounter = 0;
numberofRelevantRetrievedCounter = 0;
cout<<"Insert QueryID:\t"<<queryid<<"\twith number of Relevant Docs:\t"<<qrel->getNumberofRelevant(queryid)<<"\tTotalRetreived\t"<<retrieved->size()<<"\tTotal relevant retreived\t"<<relevantRetrieved->size()<<endl;
cout<<"\tTotal relevant retreived\t"<<relevantRetrieved->size()<<endl;
retrieved = new vector<Record>();
relevantRetrieved = new vector<Record>();
}
cout<<"Insert QueryID:\t"<<queryid<<"\twith number of Relevant Docs:\t"<<qrel->getNumberofRelevant(queryid)<<"\tTotalRetreived\t"<<retrieved->size();
effQueryCounter++;
vecQueryNo.push_back(queryid);
vecNumberofRelevant.push_back(qrel->getNumberofRelevant(queryid));
Expand All @@ -112,6 +113,7 @@ if (data.size() == 7) {
//adding relevant document to the relevant retreived set
if (qrel->isRelevantDoc(docId,queryid)) {
relevantRetrieved->push_back(*currrec);
cout<<"Relevant Doc:\t"<<docId<<endl;
numberofRelevantRetrievedCounter++;
}

Expand Down Expand Up @@ -239,48 +241,85 @@ if (data.size() == 7) {

void
AdhocEvaluation::writeEvaluationResult() {
//Opening file to write Query Wise Precision
ofstream evaluationQueryWise;
evaluationQueryWise.open((configobj.get_evaluationsfile()+"_QueryWisePrecision").c_str());
cout<<"_______________________________________________________"<<endl;
cout<<"Result for the run:\t"<<configobj.get_runname()<<endl;
evaluationQueryWise<<"Result for the run:\t"<<configobj.get_runname()<<endl;
cout<<"-----------------------------------------------------"<<endl;
cout<<"Query wise Precision:\t"<<endl;
evaluationQueryWise<<"Query wise Precision:\t"<<endl;
cout<<"_______________________________________________________"<<endl;
cout<<numberofEffQuery;
for(int i = 0;i<numberofEffQuery;i++) {
cout<<"Precision of Query:\t"<<queryNo[i]<<"\tis : "<<averagePrecisionofEachQuery[i]<<endl;
evaluationQueryWise<<"Precision of Query:\t"<<queryNo[i]<<"\tis : "<<averagePrecisionofEachQuery[i]<<endl;
cout<<"-----------------------------------------------------"<<endl;

}
//Closing file to which QueryWise Precision is written
evaluationQueryWise.close();
//Opening file to write Run Statistics
ofstream evaluationRunStatistics;
evaluationRunStatistics.open((configobj.get_evaluationsfile()+"_RunStatistics").c_str());
evaluationQueryWise<<"Result for the run:\t"<<configobj.get_runname()<<endl;
cout<<"_______________________________________________________"<<endl;
cout<<"Evaluation:\t"<<endl;
evaluationRunStatistics<<"Evaluation:\t"<<endl;
cout<<"_______________________________________________________"<<endl;
cout<<"Number of Queries:\t"<<numberofEffQuery<<endl;
evaluationRunStatistics<<"Number of Queries:\t"<<numberofEffQuery<<endl;
cout<<"-----------------------------------------------------"<<endl;
cout<<"Retrieved:\t"<<totalNumberofRetrieved<<endl;
evaluationRunStatistics<<"Retrieved:\t"<<totalNumberofRetrieved<<endl;
cout<<"-----------------------------------------------------"<<endl;
cout<<"Relevant Retrieved:\t"<<totalNumberofRelevantRetrieved<<endl;
evaluationRunStatistics<<"Relevant Retrieved:\t"<<totalNumberofRelevantRetrieved<<endl;
cout<<"-----------------------------------------------------"<<endl;
cout<<"Relevant in Qrel:\t"<<totalNumberofRelevant<<endl;
evaluationRunStatistics<<"Relevant in Qrel:\t"<<totalNumberofRelevant<<endl;
cout<<"_______________________________________________________"<<endl;
cout<<"Mean Evaluation:\t"<<endl;
evaluationRunStatistics<<"Mean Evaluation:\t"<<endl;
cout<<"_______________________________________________________"<<endl;
cout<<"Mean Average Precision :\t"<<meanAveragePrecision<<endl;
evaluationRunStatistics<<"Mean Average Precision :\t"<<meanAveragePrecision<<endl;
cout<<"-----------------------------------------------------"<<endl;
cout<<"Mean Relevance Precision :\t"<<meanRelevantPrecision<<endl;
evaluationRunStatistics<<"Mean Relevance Precision :\t"<<meanRelevantPrecision<<endl;
// Closing file to which Run Statistics are written.
evaluationRunStatistics.close();
//Opening file to write Precision At rank result.
ofstream evaluationPrecisionAtRank;
evaluationPrecisionAtRank.open((configobj.get_evaluationsfile()+"_PrecisionAtRank").c_str());
evaluationPrecisionAtRank<<"Result for the run:\t"<<configobj.get_runname()<<endl;
cout<<"_______________________________________________________"<<endl;
cout<<"Precision At Rank:"<<endl;
evaluationPrecisionAtRank<<"Precision At Rank:"<<endl;
cout<<"_______________________________________________________"<<endl;
for ( int precisionRank = 0;precisionRank < 14;precisionRank++) {
cout<<"Precision at Rank:\t"<<PRECISION_RANK[precisionRank]<<"\tis:\t"<<precisionAtRank[PRECISION_RANK[precisionRank]]<<endl;
evaluationPrecisionAtRank<<"Precision at Rank:\t"<<PRECISION_RANK[precisionRank]<<"\tis:\t"<<precisionAtRank[PRECISION_RANK[precisionRank]]<<endl;
cout<<"-----------------------------------------------------"<<endl;
}
//Closing file to which precision @ rank results are written.
evaluationPrecisionAtRank.close();
//Opening file where precision @recall results are written.
ofstream evaluationPrecisionAtRecall;
evaluationPrecisionAtRecall.open((configobj.get_evaluationsfile()+"_PrecisionAtRecall").c_str());
evaluationPrecisionAtRecall<<"Result for the run:\t"<<configobj.get_runname()<<endl;

cout<<"_______________________________________________________"<<endl;
cout<<"Precision At Recall:"<<endl;
cout<<"_______________________________________________________"<<endl;
for ( int precisionPercentage = 0;precisionPercentage < 11;precisionPercentage++) {
cout<<"Precision at Recall:\t"<<PRECISION_PERCENTAGES[precisionPercentage]<<"\tis:\t"<<precisionAtRecall[PRECISION_PERCENTAGES[precisionPercentage]]<<endl;
evaluationPrecisionAtRecall<<"Precision at Recall:\t"<<PRECISION_PERCENTAGES[precisionPercentage]<<"\tis:\t"<<precisionAtRecall[PRECISION_PERCENTAGES[precisionPercentage]]<<endl;
cout<<"-----------------------------------------------------"<<endl;
}
cout<<"_______________________________________________________"<<endl;
//closing file to which precision At recall results are written.
evaluationPrecisionAtRecall.close();
}

int main(int argc,char **argv) {
Expand Down
9 changes: 5 additions & 4 deletions trec_qrel.cc
Expand Up @@ -131,6 +131,7 @@ bool
TrecQrel::isRelevantDoc(string docno,string queryid) {
for (int i = 0;i < getNumberofQueries();i++) {
if (qrelPerQuery[i].queryid.compare(queryid) == 0) {
//cout<<"query in relevant:\t"<<qrelPerQuery[i].queryid<<endl;
return qrelPerQuery[i].isRelevant(docno);
}
}
Expand All @@ -152,11 +153,11 @@ int main(int argc,char **argv)
CONFIG_TREC config;
config.setup_config(string(argv[1]));
TrecQrel *qrl =new TrecQrel(config);
set<string> rel = qrl->qrelPerQuery[1].nonRelDocuments;
cout<< "Queryid"<<qrl->qrelPerQuery[1].queryid<<endl;
set<string> rel = qrl->getRelevantDocument(string(argv[2]));
cout<< "Queryid"<<string(argv[2])<<endl;
for ( set<string>::iterator docs = rel.begin() ;docs != rel.end() ; docs++) {
// cout<<"Relevant Document:\t"<<*docs<<endl;
cout<<"Relevant Document:\t"<<*docs<<endl;
}
cout<<"IS Relevan"<<qrl->isRelevantDoc(argv[2],argv[3]) <<"Grade"<<qrl->getGrade(argv[2],argv[3])<<endl;
//cout<<"IS Relevan"<<qrl->isRelevantDoc(argv[2],argv[3]) <<"Grade"<<qrl->getGrade(argv[2],argv[3])<<endl;
}
*/

0 comments on commit 2c246e7

Please sign in to comment.