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

TextQueryRetMethod.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  *
00003  *  Original source copyright (c) 2001, Carnegie Mellon University.
00004  *  See copyright.cmu for details.
00005  *  Modifications copyright (c) 2002, University of Massachusetts.
00006  *  See copyright.umass for details.
00007  *
00008  *==========================================================================
00009  */
00010 
00011 
00012 #ifndef _TEXTQUERYRETMETHOD_HPP
00013 #define _TEXTQUERYRETMETHOD_HPP
00014 
00015 
00016 #include "RetrievalMethod.hpp"
00017 #include "TermQuery.hpp"
00018 #include "TextQueryRep.hpp"
00019 #include "DocumentRep.hpp"
00020 #include "PassageRep.hpp"
00021 #include "ScoreFunction.hpp"
00022 #include "ScoreAccumulator.hpp"
00023 #include "FreqVector.hpp"
00024 
00025 namespace lemur 
00026 {
00027   namespace api 
00028   {
00029     
00031 
00078     class TextQueryRetMethod : public RetrievalMethod {
00079     public:
00082       TextQueryRetMethod(const Index &ind, ScoreAccumulator & accumulator);
00083 
00086       virtual ~TextQueryRetMethod() {
00087         if (cacheDocReps) {
00088           for (int i = 0; i < docRepsSize; i++) delete(docReps[i]);
00089           delete[](docReps);
00090         }
00091       }
00092 
00094       virtual TextQueryRep *computeTextQueryRep(const TermQuery &qry)=0;
00096       virtual TextQueryRep *computeTextQueryRep(DOCID_T docid){
00097         return NULL; 
00098       } // need to implement for other ret methods.
00100       virtual QueryRep *computeQueryRep(const Query &qry); 
00101 
00103       virtual double scoreDoc(const QueryRep &qry, DOCID_T docID);
00105       virtual void scoreCollection(const QueryRep &qry, IndexedRealVector &results);
00107       virtual void scoreCollection(DOCID_T docid, IndexedRealVector &results);
00108   
00110       virtual DocumentRep *computeDocRep(DOCID_T docID) =0;
00112       virtual ScoreFunction *scoreFunc() = 0;
00114       virtual void updateQuery(QueryRep &qryRep, const DocIDSet &relDocs) {
00115         updateTextQuery(*((TextQueryRep *)(&qryRep)), relDocs);
00116       }
00117 
00119       virtual void updateTextQuery(TextQueryRep &qryRep, 
00120                                    const DocIDSet &relDocs)=0;
00121 
00123 
00126       virtual void scoreInvertedIndex(const QueryRep &qryRep, 
00127                                       IndexedRealVector &scores, 
00128                                       bool scoreAll=false);
00129 
00130       virtual double scoreDocVector(const TextQueryRep &qry, DOCID_T docID, 
00131                                     lemur::utility::FreqVector &docVector);
00139       virtual double scoreDocPassages(const TermQuery &qRep, DOCID_T docID, 
00140                                       lemur::retrieval::PassageScoreVector &scores, 
00141                                       int psgSize, int overlap);
00142   
00143     protected:
00144       ScoreAccumulator &scAcc;
00146       DocumentRep **docReps;
00148       bool cacheDocReps;
00150       int docRepsSize;
00151     };
00152 
00153 
00154     //=============== inlines ========================================
00155 
00156     inline QueryRep *TextQueryRetMethod::computeQueryRep(const Query &qry) { 
00157       if (const TermQuery *q = dynamic_cast<const TermQuery *>(&qry))
00158         return (computeTextQueryRep(*q));
00159       else 
00160         LEMUR_THROW(LEMUR_RUNTIME_ERROR, "TextQueryRetMethod expects a TermQuery object");
00161     }
00162   }
00163 }
00164 
00165 #endif /* _TEXTQUERYRETMETHOD_HPP */

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