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 _RETRIEVALMETHOD_HPP 00014 #define _RETRIEVALMETHOD_HPP 00015 00016 00017 #include "Index.hpp" 00018 #include "WeightedIDSet.hpp" 00019 #include "IndexedReal.hpp" 00020 00021 namespace lemur 00022 { 00023 namespace api 00024 { 00025 00026 //------------------------------------------------------------ 00027 // Abstract Interface for A Query 00028 //------------------------------------------------------------ 00029 00031 class Query { 00032 public: 00033 virtual ~Query() {} 00034 00035 virtual const string& id() const { return qid; } 00036 virtual void id(const string& str) { qid = str; } 00037 00038 protected: 00039 string qid; 00040 }; 00041 00043 00044 class QueryRep { 00045 public: 00046 virtual ~QueryRep(){} 00047 }; 00048 00049 00050 //------------------------------------------------------------ 00051 // Abstract Interface for Feedback Document Subset 00052 //------------------------------------------------------------ 00053 00055 typedef lemur::utility::WeightedIDSet DocIDSet; 00056 00057 00058 //------------------------------------------------------------ 00059 // Abstract Interface for A Retrieval Method/Model 00060 //------------------------------------------------------------ 00061 00062 00063 00074 class RetrievalMethod { 00075 public: 00076 RetrievalMethod(const Index &collectionIndex) : ind(collectionIndex) {} 00077 virtual ~RetrievalMethod() {} 00078 00080 virtual QueryRep *computeQueryRep(const Query &qry)=0; 00081 00083 virtual double scoreDoc(const QueryRep &qry, DOCID_T docID)=0; 00084 00086 00089 virtual void scoreDocSet(const QueryRep &qry, const DocIDSet &docSet, IndexedRealVector &results); 00090 00092 00099 virtual void scoreCollection(const QueryRep &qry, IndexedRealVector &results); 00100 00102 virtual void updateQuery (QueryRep &qryRep, const DocIDSet &relDocs) = 0; 00103 00104 protected: 00105 const Index &ind; 00106 }; 00107 } 00108 } 00109 00110 #endif /* _RETRIEVALMETHOD_HPP */