Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ResultFile.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2001 Carnegie Mellon University.  All Rights Reserved.
00003  *
00004  * Use of the Lemur Toolkit for Language Modeling and Information Retrieval
00005  * is subject to the terms of the software license set forth in the LICENSE
00006  * file included with this software, and also available at
00007  * http://www.lemurproject.org/license.html
00008  *
00009  *==========================================================================
00010  */
00011 
00012 
00013 #ifndef _RESULTFILE_HPP
00014 #define _RESULTFILE_HPP
00015 
00016 #include "common_headers.hpp"
00017 #include "Index.hpp"
00018 #include "IndexedReal.hpp"
00019 #include "ISet.hpp"
00020 #include "String.hpp"
00021 namespace lemur 
00022 {
00023   namespace utility
00024   {
00026     struct ResultEntry {
00027     public:
00028       String key;
00029       unsigned int Hash() const { return key.Hash();}
00030       unsigned int hash() const { return Hash();} 
00031       bool operator==(const ResultEntry entry) { return (entry.key ==  this->key);}
00032       lemur::api::IndexedRealVector *res;
00033     };
00034   }
00035 }
00036 namespace lemur 
00037 {
00038   namespace api
00039   {
00041 
00042     class ResultFile {
00043     public:
00044       ResultFile(bool TRECFormat = true) : trecFmt (TRECFormat), resTable(NULL) {
00045         resTable = new lemur::utility::ISet<lemur::utility::ResultEntry>(50);
00046       }
00047   
00048       ~ResultFile() { delete resTable;}
00049 
00051       void openForRead(istream &is, Index &index);
00052   
00054       void load(istream &is, Index &index);
00055 
00057       void getResult(const string& expectedQID, IndexedRealVector &res);
00058 
00060       bool findResult(const string& queryID, IndexedRealVector *&res);
00061   
00063       void openForWrite( ostream &os, Index &index) {
00064     
00065         outStr = &os;
00066         ind = &index;
00067       }
00068 
00070 
00071       void writeResults(const string& queryID, IndexedRealVector *results, int maxCountOfResult);
00072   
00073     private:
00074 
00075       bool readLine();
00076 
00077       bool trecFmt;
00078 
00079       //  char curQID[300];
00080       string curQID;
00081       char curDID[300];
00082       double curSC;
00083       Index *ind;
00084       istream *inStr;
00085       ostream *outStr;
00086       bool eof;
00087 
00088       lemur::utility::ISet<lemur::utility::ResultEntry> * resTable;
00089 
00090     };
00091   }
00092 }
00093 #endif /* _RESULTFILE_HPP */

Generated on Tue Jun 15 11:02:55 2010 for Lemur by doxygen 1.3.4