00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _XLINGDOCMODEL_HPP
00014 #define _XLINGDOCMODEL_HPP
00015
00016 #include "RetrievalMethod.hpp"
00017 #include "Index.hpp"
00018 #include "DocumentRep.hpp"
00019
00020 namespace lemur
00021 {
00022 namespace retrieval
00023 {
00024
00027 class XLingDocModel : public lemur::api::DocumentRep {
00028 public:
00035 XLingDocModel(lemur::api::DOCID_T docID, const lemur::api::Index *ind,
00036 double l, double nt, bool sM = false) :
00037 lemur::api::DocumentRep(docID, ind->docLength(docID)), refIndex(ind), lambda(l),
00038 numTerms(nt), docBasedSmooth(sM) {
00039 };
00040
00041 ~XLingDocModel() {};
00046 virtual double termWeight(lemur::api::TERMID_T termID, const lemur::api::DocInfo *info) const {
00047
00048 double p_doc = info->termCount()/(double)docLength;
00049 double p_gen;
00050 if (docBasedSmooth)
00051 p_gen = refIndex->docCount(termID)/numTerms;
00052 else
00053 p_gen = refIndex->termCount(termID)/numTerms;
00054 return ((lambda * p_doc) + ((1 - lambda) * p_gen));
00055 }
00056
00059 virtual double scoreConstant() const {
00060 return lambda;
00061 }
00062
00063 protected:
00065 const lemur::api::Index *refIndex;
00067 double numTerms;
00069 double lambda;
00071 bool docBasedSmooth;
00072 };
00073 }
00074 }
00075
00076 #endif