Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

XLingDocModel.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 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 
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     //    double p_doc = info->termCount()/(double)refIndex->docLength(id);
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 /* _XLINGDOCMODEL_HPP */

Generated on Wed Nov 3 12:59:08 2004 for Lemur Toolkit by doxygen1.2.18