Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound 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 
00023 struct ResultEntry {
00024 public:
00025   String key;
00026   unsigned int Hash() const { return key.Hash();}
00027   unsigned int hash() const { return Hash();} 
00028   bool operator==(const ResultEntry entry) { return (entry.key ==  this->key);}  IndexedRealVector *res;
00029 };
00030 
00032 
00033 class ResultFile {
00034 public:
00035   ResultFile(bool TRECFormat = true) : trecFmt (TRECFormat), resTable(NULL) {
00036     resTable = new ISet<ResultEntry>(50);
00037   }
00038   
00039   ~ResultFile() { delete resTable;}
00040 
00042   void openForRead(istream &is, Index &index);
00043   
00045   void load(istream &is, Index &index);
00046 
00048   void getResult(const string& expectedQID, IndexedRealVector &res);
00049 
00051   bool findResult(const string& queryID, IndexedRealVector *&res);
00052   
00054   void openForWrite( ostream &os, Index &index) {
00055     
00056     outStr = &os;
00057     ind = &index;
00058   }
00059 
00061 
00062   void writeResults(const string& queryID, IndexedRealVector *results, int maxCountOfResult);
00063   
00064 private:
00065 
00066   bool readLine();
00067 
00068   bool trecFmt;
00069 
00070   //  char curQID[300];
00071   string curQID;
00072   char curDID[300];
00073   double curSC;
00074   Index *ind;
00075   istream *inStr;
00076   ostream *outStr;
00077   bool eof;
00078 
00079   ISet<ResultEntry> * resTable;
00080 
00081 };
00082 
00083 
00084 #endif /* _RESULTFILE_HPP */
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 

Generated on Wed Nov 3 12:59:03 2004 for Lemur Toolkit by doxygen1.2.18