00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
00044 return scoreOccurrence( occurrences, contextSize );
00045 }
00046 };
00047
00048 #endif // INDRI_DIRICHLETTERMSCOREFUNCTION_HPP