Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

IndriRetMethod.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2003-2004 University of Massachusetts.  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 #ifndef _INDRIRETMETHOD_HPP
00012 #define _INDRIRETMETHOD_HPP
00013 
00014 #include "LemurIndriIndex.hpp"
00015 #include "TextQueryRep.hpp"
00016 #include "RetrievalMethod.hpp"
00017 
00019 class IndriQueryModel : public QueryRep {
00020 public:
00021   IndriQueryModel(const TermQuery &qry) {
00022     // collect terms (with operators) into a single string.
00023     // could also collect real terms for matchinfo use here...
00024 
00025     qry.startTermIteration();
00026     while (qry.hasMore()) {
00027       const Term *t = qry.nextTerm();
00028       realQuery += t->spelling();
00029       realQuery += " ";
00030     }
00031   }
00032   
00033   virtual ~IndriQueryModel() {
00034   }
00035 
00036   const string &getQuery() const {return realQuery;}
00037   // for update method.
00038   void updateQuery(const string &newQuery) const { realQuery = newQuery;}
00039 
00040 private:
00041   mutable string realQuery;
00042 };
00043 
00044 class IndriRetMethod : public RetrievalMethod {
00045 public:
00046   // parameters? want to get the rules in certainly...
00047   IndriRetMethod(const Index &dbIndex);
00048 
00050   virtual ~IndriRetMethod();
00052   virtual void setParams(Parameters *parms);
00054   virtual void setStopwords(const string& stopfile) ;
00056   virtual void scoreCollection(const QueryRep &qry, 
00057                                IndexedRealVector &results);
00059   virtual void scoreCollection(const string &qry, 
00060                                IndexedRealVector &results);
00062   virtual QueryRep *computeQueryRep(const Query &qry) {
00063     if (const TermQuery *q = dynamic_cast<const TermQuery *>(&qry))
00064       return (new IndriQueryModel(*q));
00065     else LEMUR_THROW(LEMUR_RUNTIME_ERROR, 
00066                      "IndriRetMethod expects query of type TermQuery");
00067   } 
00068 
00070   virtual void scoreDocSet(const QueryRep &qry, const DocIDSet &docSet, 
00071                            IndexedRealVector &results);
00072 
00074   virtual double scoreDoc(const QueryRep &qry, DOCID_T docID);
00075 
00077   virtual void updateQuery(QueryRep &qryRep, const DocIDSet &relDocs);
00078 private:
00079   class QueryEnvironment *env;
00080   Parameters *params;
00081 };
00082 
00083 #endif /* _INDRIRETMETHOD_HPP */

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