00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _STRUCTQUERYRETMETHOD_HPP
00017 #define _STRUCTQUERYRETMETHOD_HPP
00018
00019 #include "RetrievalMethod.hpp"
00020 #include "StructQueryRep.hpp"
00021 #include "DocumentRep.hpp"
00022 #include "ScoreFunction.hpp"
00023 #include "ScoreAccumulator.hpp"
00024 #include "FreqVector.hpp"
00025
00026
00027
00028
00029
00030
00049 class StructQueryRetMethod : public RetrievalMethod {
00050 public:
00051 StructQueryRetMethod(InvFPIndex &ind, ScoreAccumulator & accumulator) :
00052 RetrievalMethod(ind), scAcc(accumulator), index(ind){}
00053 virtual ~StructQueryRetMethod() {}
00055 virtual StructQueryRep *computeStructQueryRep(StructQuery &qry)=0;
00056
00058 virtual QueryRep *computeQueryRep(Query &qry);
00060 virtual double scoreDocVector(StructQueryRep &qRep, int docID, FreqVector &docVector);
00062 virtual double scoreDoc(QueryRep &qry, int docID);
00064 virtual void scoreCollection(QueryRep &qry, IndexedRealVector &results);
00065
00067 virtual DocumentRep *computeDocRep(int docID) =0;
00069 virtual ScoreFunction *scoreFunc() = 0;
00071 virtual void updateQuery(QueryRep &qryRep, DocIDSet &relDocs) {
00072 updateStructQuery(*((StructQueryRep *)(&qryRep)), relDocs);
00073 }
00074
00076 virtual void updateStructQuery(StructQueryRep &qryRep, DocIDSet &relDocs)=0;
00077
00079 virtual void scoreInvertedIndex(QueryRep &qryRep, IndexedRealVector &scores, bool scoreAll=false);
00080
00081 protected:
00082 ScoreAccumulator &scAcc;
00083 InvFPIndex &index;
00084 };
00085
00087 class StructQueryScoreFunc : public ScoreFunction {
00088 public:
00090 virtual double evalQuery(QueryNode *qn, DocumentRep *dRep) {
00091 return qn->eval(dRep);
00092 }
00094 virtual double adjustedScore(double w, QueryNode *qn) {
00095 return w;
00096 }
00097 };
00098
00099
00100
00101 inline QueryRep *StructQueryRetMethod::computeQueryRep(Query &qry) {
00102 StructQuery *q = static_cast<StructQuery *>(&qry);
00103 return (computeStructQueryRep(*q));
00104 }
00105
00106 #endif
00107
00108
00109
00110