Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class 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 namespace indri
00018 {
00019   namespace api
00020   {
00021     class QueryEnvironment;
00022   }
00023 }
00024 namespace lemur 
00025 {
00026   namespace retrieval 
00027   {
00028     
00030     class IndriQueryModel : public lemur::api::QueryRep {
00031     public:
00032       IndriQueryModel(const lemur::api::TermQuery &qry) {
00033         // collect terms (with operators) into a single string.
00034         // could also collect real terms for matchinfo use here...
00035 
00036         qry.startTermIteration();
00037         while (qry.hasMore()) {
00038           const lemur::api::Term *t = qry.nextTerm();
00039           realQuery += t->spelling();
00040           realQuery += " ";
00041         }
00042       }
00043   
00044       virtual ~IndriQueryModel() {
00045       }
00046 
00047       const string &getQuery() const {return realQuery;}
00048       // for update method.
00049       void updateQuery(const string &newQuery) const { realQuery = newQuery;}
00050 
00051     private:
00052       mutable string realQuery;
00053     };
00055     class IndriRetMethod : public lemur::api::RetrievalMethod {
00056     public:
00057       // parameters? want to get the rules in certainly...
00058       IndriRetMethod(const lemur::api::Index &dbIndex);
00059 
00061       virtual ~IndriRetMethod();
00063       virtual void setParams(indri::api::Parameters *parms);
00065       virtual void setStopwords(const string& stopfile) ;
00067       virtual void scoreCollection(const lemur::api::QueryRep &qry, 
00068                                    lemur::api::IndexedRealVector &results);
00070       virtual void scoreCollection(const string &qry, 
00071                                    lemur::api::IndexedRealVector &results);
00073       virtual lemur::api::QueryRep *computeQueryRep(const lemur::api::Query &qry) {
00074         if (const lemur::api::TermQuery *q = dynamic_cast<const lemur::api::TermQuery *>(&qry))
00075           return (new IndriQueryModel(*q));
00076         else LEMUR_THROW(LEMUR_RUNTIME_ERROR, 
00077                          "IndriRetMethod expects query of type TermQuery");
00078       } 
00079 
00081       virtual void scoreDocSet(const lemur::api::QueryRep &qry, 
00082                                const lemur::api::DocIDSet &docSet, 
00083                                lemur::api::IndexedRealVector &results);
00084 
00086       virtual double scoreDoc(const lemur::api::QueryRep &qry, 
00087                               lemur::api::DOCID_T docID);
00088 
00090       virtual void updateQuery(lemur::api::QueryRep &qryRep, 
00091                                const lemur::api::DocIDSet &relDocs);
00092     private:
00093       indri::api::QueryEnvironment *env;
00094       indri::api::Parameters *params;
00095     };
00096   }
00097 }
00098 
00099 
00100 #endif /* _INDRIRETMETHOD_HPP */

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