Section navigation

Public classSealed TfIdfDoubleNormSimilarity

Namespace
Rowles.LeanCorpus.Search.Scoring
Assembly
Rowles.LeanCorpus.dll

Double-normalised TF-IDF scoring model. Combines augmented/pivoted term frequency (reducing the impact of high-TF terms) with pivoted document length normalisation (less aggressive penalty for long documents).

tf_norm = K + (1-K) * tf / (tf + K).

len_norm = 1 / ((1-s) + s * dl/avgdl).

Score = tf_norm * idf * len_norm.

Default: K=0.5, s=0.2.

public sealed class TfIdfDoubleNormSimilarity : ISimilarity
Inheritance
TfIdfDoubleNormSimilarity
Implements

Public constructor TfIdfDoubleNormSimilarity(float, float)

Initialises a new instance with the specified pivot and slope parameters.

Public field Instance

Gets the shared singleton instance with default parameters (K=0.5, s=0.2).

Public property RequiresCollectionStatistics

Whether this similarity requires collection-level statistics (total term frequency and total terms in collection) for scoring.

Public method PrecomputeFactors(int, int, float)

Precomputes factors constant for a given term across all documents.

Public method Score(int, int, float, int, int)

Computes the score for a single term occurrence in a document.

Public method ScorePrecomputed(float, float, int, int)

Scores using precomputed factors for hot-path scoring.