Skip to contents

IDF-weighted saturated term frequency with length normalisation.

Usage

morie_kamath_bm25_score(q_terms, doc_terms, idf, avgdl, k1 = 1.5, b = 0.75)

Arguments

q_terms

Query terms.

doc_terms

Document terms.

idf

Named IDF vector or one value per query term.

avgdl

Average document length.

k1, b

BM25 parameters.

Value

List with estimate, per_term, term_frequencies.

Examples

morie_kamath_bm25_score(c("cat", "dog"), c("cat", "cat", "fish"),
    c(cat = 1.5, dog = 2), 3)
#> $estimate
#> [1] 2.142857
#> 
#> $score
#> [1] 2.142857
#> 
#> $per_term
#>      cat      dog 
#> 2.142857 0.000000 
#> 
#> $term_frequencies
#> [1] 2 0
#> 
#> $doc_length
#> [1] 3
#> 
#> $avgdl
#> [1] 3
#> 
#> $k1
#> [1] 1.5
#> 
#> $b
#> [1] 0.75
#> 
#> $n
#> [1] 2
#> 
#> $method
#> [1] "BM25 relevance score (Kamath Ch 7)"
#>