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
00022 class XLingDocModel : public DocumentRep {
00023 public:
00030 XLingDocModel(DOCID_T docID, const Index *ind, double l, double nt,
00031 bool sM = false) :
00032 DocumentRep(docID, ind->docLength(docID)), refIndex(ind), lambda(l),
00033 numTerms(nt), docBasedSmooth(sM) {
00034 };
00035
00036 ~XLingDocModel() {};
00041 virtual double termWeight(TERMID_T termID, const DocInfo *info) const {
00042
00043 double p_doc = info->termCount()/(double)docLength;
00044 double p_gen;
00045 if (docBasedSmooth)
00046 p_gen = refIndex->docCount(termID)/numTerms;
00047 else
00048 p_gen = refIndex->termCount(termID)/numTerms;
00049 return ((lambda * p_doc) + ((1 - lambda) * p_gen));
00050 }
00051
00054 virtual double scoreConstant() const {
00055 return lambda;
00056 }
00057
00058 protected:
00060 const Index *refIndex;
00062 double numTerms;
00064 double lambda;
00066 bool docBasedSmooth;
00067 };
00068
00069 #endif