Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class 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 
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         //    double p_doc = info->termCount()/(double)refIndex->docLength(id);
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 /* _XLINGDOCMODEL_HPP */

Generated on Tue Jun 15 11:02:56 2010 for Lemur by doxygen 1.3.4