Safe Haskell | Safe-Inferred |
---|
An implementation of BM25F ranking. See:
- A quick overview: http://en.wikipedia.org/wiki/Okapi_BM25
- The Probabilistic Relevance Framework: BM25 and Beyond http://www.soi.city.ac.uk/~ser/papers/foundations_bm25_review.pdf
- An Introduction to Information Retrieval http://nlp.stanford.edu/IR-book/pdf/irbookonlinereading.pdf
- score :: (Ix field, Bounded field, Ix feature, Bounded feature) => Context term field feature -> Doc term field feature -> [term] -> Float
- data Context term field feature = Context {
- numDocsTotal :: !Int
- avgFieldLength :: field -> Float
- numDocsWithTerm :: term -> Int
- paramK1 :: !Float
- paramB :: field -> Float
- fieldWeight :: field -> Float
- featureWeight :: feature -> Float
- featureFunction :: feature -> FeatureFunction
- data FeatureFunction
- data Doc term field feature = Doc {
- docFieldLength :: field -> Int
- docFieldTermFrequency :: field -> term -> Int
- docFeatureValue :: feature -> Float
- data Explanation field feature term = Explanation {
- overallScore :: Float
- termScores :: [(term, Float)]
- nonTermScores :: [(feature, Float)]
- termFieldScores :: [(term, [(field, Float)])]
- explain :: (Ix field, Bounded field, Ix feature, Bounded feature) => Context term field feature -> Doc term field feature -> [term] -> Explanation field feature term
The ranking function
score :: (Ix field, Bounded field, Ix feature, Bounded feature) => Context term field feature -> Doc term field feature -> [term] -> FloatSource
The BM25F score for a document for a given set of terms.
data Context term field feature Source
Context | |
|
data FeatureFunction Source
LogarithmicFunction Float | log (lambda_i + f_i) |
RationalFunction Float | f_i / (lambda_i + f_i) |
SigmoidFunction Float Float | 1 / (lambda + exp(-(lambda' * f_i)) |
data Doc term field feature Source
Doc | |
|
Explaining the score
data Explanation field feature term Source
A breakdown of the BM25F score, to explain somewhat how it relates to the inputs, and so you can compare the scores of different documents.
Explanation | |
|
Functor (Explanation field feature) | |
(Show field, Show feature, Show term) => Show (Explanation field feature term) |