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

DirichletTermScoreFunction.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 //
00014 // DirichletTermScoreFunction
00015 //
00016 // 26 January 2004 - tds
00017 //
00018 
00019 #ifndef INDRI_DIRICHLETTERMSCOREFUNCTION_HPP
00020 #define INDRI_DIRICHLETTERMSCOREFUNCTION_HPP
00021 
00022 #include <math.h>
00023 
00024 class DirichletTermScoreFunction : public TermScoreFunction {
00025 private:
00026   double _mu;
00027   double _collectionFrequency;
00028   double _muTimesCollectionFrequency;
00029 
00030 public:
00031   DirichletTermScoreFunction( double mu, double collectionFrequency ) {
00032     _collectionFrequency = collectionFrequency;
00033     _mu = mu;
00034     _muTimesCollectionFrequency = _mu * _collectionFrequency;
00035   }
00036 
00037   double scoreOccurrence( int occurrences, int contextSize ) {
00038     double seen = ( double(occurrences) + _muTimesCollectionFrequency ) / ( double(contextSize) + _mu );
00039     return log( seen );
00040   }
00041 
00042   double scoreOccurrence( int occurrences, int contextSize, int documentOccurrences, int documentLength ) {
00043     // can't two-level smooth with dirichlet
00044     return scoreOccurrence( occurrences, contextSize );
00045   }
00046 };
00047 
00048 #endif // INDRI_DIRICHLETTERMSCOREFUNCTION_HPP

Generated on Wed Nov 3 12:58:53 2004 for Lemur Toolkit by doxygen1.2.18