Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound 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 //----------------------------------------------------------------------
00026 //      Abstract Interface for A Retrieval Method/Model for Text Query
00027 //----------------------------------------------------------------------
00028 
00076 class TextQueryRetMethod : public RetrievalMethod {
00077 public:
00080   TextQueryRetMethod(const Index &ind, ScoreAccumulator & accumulator);
00081 
00084   virtual ~TextQueryRetMethod() {
00085     if (cacheDocReps) {
00086       for (int i = 0; i < docRepsSize; i++) delete(docReps[i]);
00087       delete[](docReps);
00088     }
00089   }
00090 
00092   virtual TextQueryRep *computeTextQueryRep(const TermQuery &qry)=0;
00094   virtual TextQueryRep *computeTextQueryRep(DOCID_T docid){
00095     return NULL; 
00096   } // need to implement for other ret methods.
00098   virtual QueryRep *computeQueryRep(const Query &qry); 
00099 
00101   virtual double scoreDoc(const QueryRep &qry, DOCID_T docID);
00103   virtual void scoreCollection(const QueryRep &qry, IndexedRealVector &results);
00105   virtual void scoreCollection(DOCID_T docid, IndexedRealVector &results);
00106   
00108   virtual DocumentRep *computeDocRep(DOCID_T docID) =0;
00110   virtual ScoreFunction *scoreFunc() = 0;
00112   virtual void updateQuery(QueryRep &qryRep, const DocIDSet &relDocs) {
00113     updateTextQuery(*((TextQueryRep *)(&qryRep)), relDocs);
00114   }
00115 
00117   virtual void updateTextQuery(TextQueryRep &qryRep, 
00118                                const DocIDSet &relDocs)=0;
00119 
00121 
00124   virtual void scoreInvertedIndex(const QueryRep &qryRep, 
00125                                   IndexedRealVector &scores, 
00126                                   bool scoreAll=false);
00127 
00128   virtual double scoreDocVector(const TextQueryRep &qry, DOCID_T docID, 
00129                                 FreqVector &docVector);
00137   virtual double scoreDocPassages(const TermQuery &qRep, DOCID_T docID, 
00138                                   PassageScoreVector &scores, 
00139                                   int psgSize, int overlap);
00140   
00141 protected:
00142   ScoreAccumulator &scAcc;
00144   DocumentRep **docReps;
00146   bool cacheDocReps;
00148   int docRepsSize;
00149 };
00150 
00151 
00152 //=============== inlines ========================================
00153 
00154 inline QueryRep *TextQueryRetMethod::computeQueryRep(const Query &qry) { 
00155   if (const TermQuery *q = dynamic_cast<const TermQuery *>(&qry))
00156     return (computeTextQueryRep(*q));
00157   else 
00158     LEMUR_THROW(LEMUR_RUNTIME_ERROR, "TextQueryRetMethod expects a TermQuery object");
00159 }
00160 
00161 #endif /* _TEXTQUERYRETMETHOD_HPP */
00162 
00163 
00164 
00165 

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