blob: 9115bb97bf55023a1344a6880ffed78d4626f09a [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Class TFIDFSimilarity
| Apache Lucene.NET 4.8.0-beta00013 Documentation </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Class TFIDFSimilarity
| Apache Lucene.NET 4.8.0-beta00013 Documentation ">
<meta name="generator" content="docfx 2.56.2.0">
<link rel="shortcut icon" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/logo/favicon.ico">
<link rel="stylesheet" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.vendor.css">
<link rel="stylesheet" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.css">
<link rel="stylesheet" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/main.css">
<meta property="docfx:navrel" content="toc.html">
<meta property="docfx:tocrel" content="core/toc.html">
<meta property="docfx:rel" content="https://lucenenet.apache.org/docs/4.8.0-beta00009/">
</head>
<body data-spy="scroll" data-target="#affix" data-offset="120">
<span id="forkongithub"><a href="https://github.com/apache/lucenenet" target="_blank">Fork me on GitHub</a></span>
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">
<img id="logo" class="svg" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/logo/lucene-net-color.png" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search">
<ul class="level0 breadcrumb">
<li>
<a href="https://lucenenet.apache.org/docs/4.8.0-beta00009/">API</a>
<span id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</span>
</li>
</ul>
</div>
</div>
</header>
<div class="container body-content">
<div id="search-results">
<div class="search-list"></div>
<div class="sr-items">
<p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
</div>
<ul id="pagination"></ul>
</div>
</div>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity">
<h1 id="Lucene_Net_Search_Similarities_TFIDFSimilarity" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity" class="text-break">Class TFIDFSimilarity
</h1>
<div class="markdown level0 summary"><p>Implementation of <a class="xref" href="Lucene.Net.Search.Similarities.Similarity.html">Similarity</a> with the Vector Space Model.
<p>
Expert: Scoring API.
<p>TFIDFSimilarity defines the components of Lucene scoring.
Overriding computation of these components is a convenient
way to alter Lucene scoring.</p>
<p>Suggested reading:
<a href="http://nlp.stanford.edu/IR-book/html/htmledition/queries-as-vectors-1.html">
Introduction To Information Retrieval, Chapter 6</a>.
<p>The following describes how Lucene scoring evolves from
underlying information retrieval models to (efficient) implementation.
We first brief on <em>VSM Score</em>,
then derive from it <em>Lucene&apos;s Conceptual Scoring Formula</em>,
from which, finally, evolves <em>Lucene&apos;s Practical Scoring Function</em>
(the latter is connected directly with Lucene classes and methods).
<p>Lucene combines
<a href="http://en.wikipedia.org/wiki/Standard_Boolean_model">
Boolean model (BM) of Information Retrieval</a>
with
<a href="http://en.wikipedia.org/wiki/Vector_Space_Model">
Vector Space Model (VSM) of Information Retrieval</a> -
documents &quot;approved&quot; by BM are scored by VSM.
<p>In VSM, documents and queries are represented as
weighted vectors in a multi-dimensional space,
where each distinct index term is a dimension,
and weights are
<a href="http://en.wikipedia.org/wiki/Tfidf">Tf-idf</a> values.
<p>VSM does not require weights to be <em>Tf-idf</em> values,
but <em>Tf-idf</em> values are believed to produce search results of high quality,
and so Lucene is using <em>Tf-idf</em>.
<em>Tf</em> and <em>Idf</em> are described in more detail below,
but for now, for completion, let&apos;s just say that
for given term <em>t</em> and document (or query) <em>x</em>,
<em>Tf(t,x)</em> varies with the number of occurrences of term <em>t</em> in <em>x</em>
(when one increases so does the other) and
<em>idf(t)</em> similarly varies with the inverse of the
number of index documents containing term <em>t</em>.
<p><em>VSM score</em> of document <em>d</em> for query <em>q</em> is the
<a href="http://en.wikipedia.org/wiki/Cosine_similarity">
Cosine Similarity</a>
of the weighted query vectors <em>V(q)</em> and <em>V(d)</em>:
<p>
<table><tbody><tr><td>
<table><tbody><tr><td>cosine-similarity(q,d) =<br><table>
<item><small>V(q) · V(d)</small></item>
<item>–––––––––</item>
<item><small>|V(q)| |V(d)|</small></item>
</table>
</td><td></td></tr></tbody></table>
</td><td></td></tr><tr><td>VSM Score</td><td></td></tr></tbody></table>
<p>
<p>Where <em>V(q)</em> · <em>V(d)</em> is the
<a href="http://en.wikipedia.org/wiki/Dot_product">dot product</a>
of the weighted vectors,
and <em>|V(q)|</em> and <em>|V(d)|</em> are their
<a href="http://en.wikipedia.org/wiki/Euclidean_norm#Euclidean_norm">Euclidean norms</a>.</p>
<p>Note: the above equation can be viewed as the dot product of
the normalized weighted vectors, in the sense that dividing
<em>V(q)</em> by its euclidean norm is normalizing it to a unit vector.
<p>Lucene refines <em>VSM score</em> for both search quality and usability:
<ul><li>Normalizing <em>V(d)</em> to the unit vector is known to be problematic in that
it removes all document length information.
For some documents removing this info is probably ok,
e.g. a document made by duplicating a certain paragraph <em>10</em> times,
especially if that paragraph is made of distinct terms.
But for a document which contains no duplicated paragraphs,
this might be wrong.
To avoid this problem, a different document length normalization
factor is used, which normalizes to a vector equal to or larger
than the unit vector: <em>doc-len-norm(d)</em>.
</li><li>At indexing, users can specify that certain documents are more
important than others, by assigning a document boost.
For this, the score of each document is also multiplied by its boost value
<em>doc-boost(d)</em>.
</li><li>Lucene is field based, hence each query term applies to a single
field, document length normalization is by the length of the certain field,
and in addition to document boost there are also document fields boosts.
</li><li>The same field can be added to a document during indexing several times,
and so the boost of that field is the multiplication of the boosts of
the separate additions (or parts) of that field within the document.
</li><li>At search time users can specify boosts to each query, sub-query, and
each query term, hence the contribution of a query term to the score of
a document is multiplied by the boost of that query term <em>query-boost(q)</em>.
</li><li>A document may match a multi term query without containing all
the terms of that query (this is correct for some of the queries),
and users can further reward documents matching more query terms
through a coordination factor, which is usually larger when
more terms are matched: <em>coord-factor(q,d)</em>.
</li></ul>
<p>Under the simplifying assumption of a single field in the index,
we get <em>Lucene&apos;s Conceptual scoring formula</em>:
<p>
<table><tbody><tr><td>
<table><tbody><tr><td>
score(q,d) =<br><font color="#FF9933">coord-factor(q,d)</font> ·<br><font color="#CCCC00">query-boost(q)</font> ·<br>
<table><tbody><tr><td><small><font color="#993399">V(q) · V(d)</font></small></td><td></td></tr><tr><td>–––––––––</td><td></td></tr><tr><td><small><font color="#FF33CC">|V(q)|</font></small></td><td></td></tr></tbody></table>
· <font color="#3399FF">doc-len-norm(d)</font>
· <font color="#3399FF">doc-boost(d)</font>
</td><td></td></tr></tbody></table>
</td><td></td></tr><tr><td>Lucene Conceptual Scoring Formula</td><td></td></tr></tbody></table>
<p>
<p>The conceptual formula is a simplification in the sense that (1) terms and documents
are fielded and (2) boosts are usually per query term rather than per query.
<p>We now describe how Lucene implements this conceptual scoring formula, and
derive from it <em>Lucene&apos;s Practical Scoring Function</em>.
<p>For efficient score computation some scoring components
are computed and aggregated in advance:
<ul><li><em>Query-boost</em> for the query (actually for each query term)
is known when search starts.
</li><li>Query Euclidean norm <em>|V(q)|</em> can be computed when search starts,
as it is independent of the document being scored.
From search optimization perspective, it is a valid question
why bother to normalize the query at all, because all
scored documents will be multiplied by the same <em>|V(q)|</em>,
and hence documents ranks (their order by score) will not
be affected by this normalization.
There are two good reasons to keep this normalization:
<ul><li>Recall that
<a href="http://en.wikipedia.org/wiki/Cosine_similarity">
Cosine Similarity</a> can be used find how similar
two documents are. One can use Lucene for e.g.
clustering, and use a document as a query to compute
its similarity to other documents.
In this use case it is important that the score of document <em>d3</em>
for query <em>d1</em> is comparable to the score of document <em>d3</em>
for query <em>d2</em>. In other words, scores of a document for two
distinct queries should be comparable.
There are other applications that may require this.
And this is exactly what normalizing the query vector <em>V(q)</em>
provides: comparability (to a certain extent) of two or more queries.
</li><li>Applying query normalization on the scores helps to keep the
scores around the unit vector, hence preventing loss of score data
because of floating point precision limitations.
</li></ul>
</li><li>Document length norm <em>doc-len-norm(d)</em> and document
boost <em>doc-boost(d)</em> are known at indexing time.
They are computed in advance and their multiplication
is saved as a single value in the index: <em>norm(d)</em>.
(In the equations below, <em>norm(t in d)</em> means <em>norm(field(t) in doc d)</em>
where <em>field(t)</em> is the field associated with term <em>t</em>.)
</li></ul>
<p><em>Lucene&apos;s Practical Scoring Function</em> is derived from the above.
The color codes demonstrate how it relates
to those of the <em>conceptual</em> formula:
<p>
<table><tbody><tr><td>
<table><tbody><tr><td>
score(q,d) =<br><a href="#formula_coord"><font color="#FF9933">coord(q,d)</font></a> ·<br><a href="#formula_queryNorm"><font color="#FF33CC">queryNorm(q)</font></a> ·<br><big><big><big></big></big></big>
<big><big>(</big></big>
<a href="#formula_tf"><font color="#993399">tf(t in d)</font></a> ·<br><a href="#formula_idf"><font color="#993399">idf(t)</font></a><sup>2</sup> ·<br><a href="#formula_termBoost"><font color="#CCCC00">t.Boost</font></a> ·<br><a href="#formula_norm"><font color="#3399FF">norm(t,d)</font></a>
<big><big>)</big></big>
</td><td></td></tr><tr><td><small>t in q</small></td><td></td></tr></tbody></table>
</td><td></td></tr><tr><td>Lucene Practical Scoring Function</td><td></td></tr></tbody></table>
<p> where
<ol><li>
<a name="formula_tf"></a>
<strong><em>tf(t in d)</em></strong>
correlates to the term&apos;s <em>frequency</em>,
defined as the number of times term <em>t</em> appears in the currently scored document <em>d</em>.
Documents that have more occurrences of a given term receive a higher score.
Note that <em>tf(t in q)</em> is assumed to be <em>1</em> and therefore it does not appear in this equation,
However if a query contains twice the same term, there will be
two term-queries with that same term and hence the computation would still be correct (although
not very efficient).
The default computation for <em>tf(t in d)</em> in
DefaultSimilarity (<a class="xref" href="Lucene.Net.Search.Similarities.DefaultSimilarity.html#Lucene_Net_Search_Similarities_DefaultSimilarity_Tf_System_Single_">Tf(Single)</a>) is:
<p>
<table><tbody><tr><td>
tf(t in d) =<br>
frequency<sup><big>½</big></sup>
</td><td></td></tr></tbody></table>
<p>
<p></li><li>
<a name="formula_idf"></a>
<strong><em>idf(t)</em></strong> stands for Inverse Document Frequency. this value
correlates to the inverse of <em>DocFreq</em>
(the number of documents in which the term <em>t</em> appears).
this means rarer terms give higher contribution to the total score.
<em>idf(t)</em> appears for <em>t</em> in both the query and the document,
hence it is squared in the equation.
The default computation for <em>idf(t)</em> in
DefaultSimilarity (<a class="xref" href="Lucene.Net.Search.Similarities.DefaultSimilarity.html#Lucene_Net_Search_Similarities_DefaultSimilarity_Idf_System_Int64_System_Int64_">Idf(Int64, Int64)</a>) is:<p>
<p>
<table><tbody><tr><td>idf(t) = 1 + log <big>(</big>
<table><tbody><tr><td><small>NumDocs</small></td><td></td></tr><tr><td>–––––––––</td><td></td></tr><tr><td><small>DocFreq+1</small></td><td></td></tr></tbody></table>
<big>)</big></td><td></td></tr></tbody></table>
<p>
<p></li><li>
<a name="formula_coord"></a>
<strong><em>coord(q,d)</em></strong>
is a score factor based on how many of the query terms are found in the specified document.
Typically, a document that contains more of the query&apos;s terms will receive a higher score
than another document with fewer query terms.
this is a search time factor computed in
coord(q,d) (<a class="xref" href="Lucene.Net.Search.Similarities.TFIDFSimilarity.html#Lucene_Net_Search_Similarities_TFIDFSimilarity_Coord_System_Int32_System_Int32_">Coord(Int32, Int32)</a>)
by the Similarity in effect at search time.
<p>
</li><li><strong>
<a name="formula_queryNorm"></a>
<em>queryNorm(q)</em>
</strong>
is a normalizing factor used to make scores between queries comparable.
this factor does not affect document ranking (since all ranked documents are multiplied by the same factor),
but rather just attempts to make scores from different queries (or even different indexes) comparable.
this is a search time factor computed by the Similarity in effect at search time.<p>
<p>The default computation in
DefaultSimilarity (<a class="xref" href="Lucene.Net.Search.Similarities.DefaultSimilarity.html#Lucene_Net_Search_Similarities_DefaultSimilarity_QueryNorm_System_Single_">QueryNorm(Single)</a>)
produces a <a href="http://en.wikipedia.org/wiki/Euclidean_norm#Euclidean_norm">Euclidean norm</a>:</p>
<p>
<table><tbody><tr><td>
queryNorm(q) =<br> queryNorm(sumOfSquaredWeights)
=<br>
<table><tbody><tr><td><big>1</big></td><td></td></tr><tr><td><big>––––––––––––––</big></td><td></td></tr><tr><td>sumOfSquaredWeights<sup><big>½</big></sup></td><td></td></tr></tbody></table>
</td><td></td></tr></tbody></table>
<p>
<p>The sum of squared weights (of the query terms) is
computed by the query <a class="xref" href="Lucene.Net.Search.Weight.html">Weight</a> object.
For example, a <a class="xref" href="Lucene.Net.Search.BooleanQuery.html">BooleanQuery</a>
computes this value as:</p>
<p><p>
<table><tbody><tr><td>
sumOfSquaredWeights =<br> q.Boost <sup><big>2</big></sup>
·
<big><big><big></big></big></big>
<big><big>(</big></big>
<a href="#formula_idf">idf(t)</a> ·
<a href="#formula_termBoost">t.Boost</a>
<big><big>) <sup>2</sup> </big></big>
</td><td></td></tr><tr><td><small>t in q</small></td><td></td></tr></tbody></table>
where sumOfSquaredWeights is <a class="xref" href="Lucene.Net.Search.Weight.html#Lucene_Net_Search_Weight_GetValueForNormalization">GetValueForNormalization()</a> and
q.Boost is <a class="xref" href="Lucene.Net.Search.Query.html#Lucene_Net_Search_Query_Boost">Boost</a>
<p>
</li><li>
<a name="formula_termBoost"></a>
<strong><em>t.Boost</em></strong>
is a search time boost of term <em>t</em> in the query <em>q</em> as
specified in the query text
(see <a href="{@docRoot}/../queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Boosting_a_Term">query syntax</a>),
or as set by application calls to
<a class="xref" href="Lucene.Net.Search.Query.html#Lucene_Net_Search_Query_Boost">Boost</a>.
Notice that there is really no direct API for accessing a boost of one term in a multi term query,
but rather multi terms are represented in a query as multi
<a class="xref" href="Lucene.Net.Search.TermQuery.html">TermQuery</a> objects,
and so the boost of a term in the query is accessible by calling the sub-query
<a class="xref" href="Lucene.Net.Search.Query.html#Lucene_Net_Search_Query_Boost">Boost</a>.
<p>
</li><li>
<a name="formula_norm"></a>
<strong><em>norm(t,d)</em></strong> encapsulates a few (indexing time) boost and length factors:<p>
<p><ul><li><strong>Field boost</strong> - set
<a class="xref" href="Lucene.Net.Documents.Field.html#Lucene_Net_Documents_Field_Boost">Boost</a>
before adding the field to a document.
</li><li><strong>lengthNorm</strong> - computed
when the document is added to the index in accordance with the number of tokens
of this field in the document, so that shorter fields contribute more to the score.
LengthNorm is computed by the <a class="xref" href="Lucene.Net.Search.Similarities.Similarity.html">Similarity</a> class in effect at indexing.
</li></ul>
The <a class="xref" href="Lucene.Net.Search.Similarities.TFIDFSimilarity.html#Lucene_Net_Search_Similarities_TFIDFSimilarity_ComputeNorm_Lucene_Net_Index_FieldInvertState_">ComputeNorm(FieldInvertState)</a> method is responsible for
combining all of these factors into a single <span class="xref">System.Single</span>.</p>
<p><p>
When a document is added to the index, all the above factors are multiplied.
If the document has multiple fields with the same name, all their boosts are multiplied together:</p>
<p><p>
<table><tbody><tr><td>
norm(t,d) =<br> lengthNorm
·
<big><big><big></big></big></big><a class="xref" href="Lucene.Net.Index.IIndexableField.html#Lucene_Net_Index_IIndexableField_Boost">Boost</a></td><td></td></tr><tr><td><small>field <em><strong>f</strong></em> in <em>d</em> named as <em><strong>t</strong></em></small></td><td></td></tr></tbody></table>
Note that search time is too late to modify this <em>norm</em> part of scoring,
e.g. by using a different <a class="xref" href="Lucene.Net.Search.Similarities.Similarity.html">Similarity</a> for search.
</li></ol></p>
</div>
<div class="markdown level0 conceptual"></div>
<div class="inheritance">
<h5>Inheritance</h5>
<div class="level0"><span class="xref">System.Object</span></div>
<div class="level1"><a class="xref" href="Lucene.Net.Search.Similarities.Similarity.html">Similarity</a></div>
<div class="level2"><span class="xref">TFIDFSimilarity</span></div>
<div class="level3"><a class="xref" href="Lucene.Net.Search.Similarities.DefaultSimilarity.html">DefaultSimilarity</a></div>
</div>
<div class="inheritedMembers">
<h5>Inherited Members</h5>
<div>
<span class="xref">System.Object.Equals(System.Object)</span>
</div>
<div>
<span class="xref">System.Object.Equals(System.Object, System.Object)</span>
</div>
<div>
<span class="xref">System.Object.GetHashCode()</span>
</div>
<div>
<span class="xref">System.Object.GetType()</span>
</div>
<div>
<span class="xref">System.Object.MemberwiseClone()</span>
</div>
<div>
<span class="xref">System.Object.ReferenceEquals(System.Object, System.Object)</span>
</div>
<div>
<span class="xref">System.Object.ToString()</span>
</div>
</div>
<h6><strong>Namespace</strong>: <a class="xref" href="Lucene.Net.Search.Similarities.html">Lucene.Net.Search.Similarities</a></h6>
<h6><strong>Assembly</strong>: Lucene.Net.dll</h6>
<h5 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_syntax">Syntax</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public abstract class TFIDFSimilarity : Similarity</code></pre>
</div>
<h3 id="constructors">Constructors
</h3>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity__ctor.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.%23ctor%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L485">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity__ctor_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.#ctor*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity__ctor" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.#ctor">TFIDFSimilarity()</h4>
<div class="markdown level1 summary"><p>Sole constructor. (For invocation by subclass
constructors, typically implicit.)</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">protected TFIDFSimilarity()</code></pre>
</div>
<h3 id="methods">Methods
</h3>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_ComputeNorm_Lucene_Net_Index_FieldInvertState_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.ComputeNorm(Lucene.Net.Index.FieldInvertState)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L616">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_ComputeNorm_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.ComputeNorm*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_ComputeNorm_Lucene_Net_Index_FieldInvertState_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.ComputeNorm(Lucene.Net.Index.FieldInvertState)">ComputeNorm(FieldInvertState)</h4>
<div class="markdown level1 summary"></div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public override sealed long ComputeNorm(FieldInvertState state)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="Lucene.Net.Index.FieldInvertState.html">FieldInvertState</a></td>
<td><span class="parametername">state</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int64</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="overrides">Overrides</h5>
<div><a class="xref" href="Lucene.Net.Search.Similarities.Similarity.html#Lucene_Net_Search_Similarities_Similarity_ComputeNorm_Lucene_Net_Index_FieldInvertState_">Similarity.ComputeNorm(FieldInvertState)</a></div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_ComputeWeight_System_Single_Lucene_Net_Search_CollectionStatistics_Lucene_Net_Search_TermStatistics___.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.ComputeWeight(System.Single%2CLucene.Net.Search.CollectionStatistics%2CLucene.Net.Search.TermStatistics%5B%5D)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L659">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_ComputeWeight_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.ComputeWeight*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_ComputeWeight_System_Single_Lucene_Net_Search_CollectionStatistics_Lucene_Net_Search_TermStatistics___" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.ComputeWeight(System.Single,Lucene.Net.Search.CollectionStatistics,Lucene.Net.Search.TermStatistics[])">ComputeWeight(Single, CollectionStatistics, TermStatistics[])</h4>
<div class="markdown level1 summary"></div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public override sealed Similarity.SimWeight ComputeWeight(float queryBoost, CollectionStatistics collectionStats, params TermStatistics[] termStats)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Single</span></td>
<td><span class="parametername">queryBoost</span></td>
<td></td>
</tr>
<tr>
<td><a class="xref" href="Lucene.Net.Search.CollectionStatistics.html">CollectionStatistics</a></td>
<td><span class="parametername">collectionStats</span></td>
<td></td>
</tr>
<tr>
<td><a class="xref" href="Lucene.Net.Search.TermStatistics.html">TermStatistics</a>[]</td>
<td><span class="parametername">termStats</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="Lucene.Net.Search.Similarities.Similarity.SimWeight.html">Similarity.SimWeight</a></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="overrides">Overrides</h5>
<div><a class="xref" href="Lucene.Net.Search.Similarities.Similarity.html#Lucene_Net_Search_Similarities_Similarity_ComputeWeight_System_Single_Lucene_Net_Search_CollectionStatistics_Lucene_Net_Search_TermStatistics___">Similarity.ComputeWeight(Single, CollectionStatistics, TermStatistics[])</a></div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_Coord_System_Int32_System_Int32_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.Coord(System.Int32%2CSystem.Int32)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L501">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_Coord_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.Coord*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_Coord_System_Int32_System_Int32_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.Coord(System.Int32,System.Int32)">Coord(Int32, Int32)</h4>
<div class="markdown level1 summary"><p>Computes a score factor based on the fraction of all query terms that a
document contains. this value is multiplied into scores.</p>
<p><p>The presence of a large portion of the query terms indicates a better
match with the query, so implementations of this method usually return
larger values when the ratio between these parameters is large and smaller
values when the ratio between them is small.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public abstract override float Coord(int overlap, int maxOverlap)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><span class="parametername">overlap</span></td>
<td><p>The number of query terms matched in the document </p>
</td>
</tr>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><span class="parametername">maxOverlap</span></td>
<td><p>The total number of terms in the query </p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Single</span></td>
<td><p>A score factor based on term overlap with the query </p>
</td>
</tr>
</tbody>
</table>
<h5 class="overrides">Overrides</h5>
<div><a class="xref" href="Lucene.Net.Search.Similarities.Similarity.html#Lucene_Net_Search_Similarities_Similarity_Coord_System_Int32_System_Int32_">Similarity.Coord(Int32, Int32)</a></div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_DecodeNormValue_System_Int64_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.DecodeNormValue(System.Int64)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L626">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_DecodeNormValue_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.DecodeNormValue*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_DecodeNormValue_System_Int64_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.DecodeNormValue(System.Int64)">DecodeNormValue(Int64)</h4>
<div class="markdown level1 summary"><p>Decodes a normalization factor stored in an index.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public abstract float DecodeNormValue(long norm)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int64</span></td>
<td><span class="parametername">norm</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Single</span></td>
<td></td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_EncodeNormValue_System_Single_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.EncodeNormValue(System.Single)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L630">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_EncodeNormValue_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.EncodeNormValue*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_EncodeNormValue_System_Single_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.EncodeNormValue(System.Single)">EncodeNormValue(Single)</h4>
<div class="markdown level1 summary"><p>Encodes a normalization factor for storage in an index. </p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public abstract long EncodeNormValue(float f)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Single</span></td>
<td><span class="parametername">f</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int64</span></td>
<td></td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_GetSimScorer_Lucene_Net_Search_Similarities_Similarity_SimWeight_Lucene_Net_Index_AtomicReaderContext_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.GetSimScorer(Lucene.Net.Search.Similarities.Similarity.SimWeight%2CLucene.Net.Index.AtomicReaderContext)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L665">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_GetSimScorer_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.GetSimScorer*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_GetSimScorer_Lucene_Net_Search_Similarities_Similarity_SimWeight_Lucene_Net_Index_AtomicReaderContext_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.GetSimScorer(Lucene.Net.Search.Similarities.Similarity.SimWeight,Lucene.Net.Index.AtomicReaderContext)">GetSimScorer(Similarity.SimWeight, AtomicReaderContext)</h4>
<div class="markdown level1 summary"></div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public override sealed Similarity.SimScorer GetSimScorer(Similarity.SimWeight stats, AtomicReaderContext context)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="Lucene.Net.Search.Similarities.Similarity.SimWeight.html">Similarity.SimWeight</a></td>
<td><span class="parametername">stats</span></td>
<td></td>
</tr>
<tr>
<td><a class="xref" href="Lucene.Net.Index.AtomicReaderContext.html">AtomicReaderContext</a></td>
<td><span class="parametername">context</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="Lucene.Net.Search.Similarities.Similarity.SimScorer.html">Similarity.SimScorer</a></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="overrides">Overrides</h5>
<div><a class="xref" href="Lucene.Net.Search.Similarities.Similarity.html#Lucene_Net_Search_Similarities_Similarity_GetSimScorer_Lucene_Net_Search_Similarities_Similarity_SimWeight_Lucene_Net_Index_AtomicReaderContext_">Similarity.GetSimScorer(Similarity.SimWeight, AtomicReaderContext)</a></div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_Idf_System_Int64_System_Int64_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.Idf(System.Int64%2CSystem.Int64)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L604">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_Idf_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.Idf*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_Idf_System_Int64_System_Int64_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.Idf(System.Int64,System.Int64)">Idf(Int64, Int64)</h4>
<div class="markdown level1 summary"><p>Computes a score factor based on a term&apos;s document frequency (the number
of documents which contain the term). This value is multiplied by the
<a class="xref" href="Lucene.Net.Search.Similarities.TFIDFSimilarity.html#Lucene_Net_Search_Similarities_TFIDFSimilarity_Tf_System_Single_">Tf(Single)</a> factor for each term in the query and these products are
then summed to form the initial score for a document.</p>
<p><p>Terms that occur in fewer documents are better indicators of topic, so
implementations of this method usually return larger values for rare terms,
and smaller values for common terms.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public abstract float Idf(long docFreq, long numDocs)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int64</span></td>
<td><span class="parametername">docFreq</span></td>
<td><p>The number of documents which contain the term </p>
</td>
</tr>
<tr>
<td><span class="xref">System.Int64</span></td>
<td><span class="parametername">numDocs</span></td>
<td><p>The total number of documents in the collection </p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Single</span></td>
<td><p>A score factor based on the term&apos;s document frequency </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_IdfExplain_Lucene_Net_Search_CollectionStatistics_Lucene_Net_Search_TermStatistics_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.IdfExplain(Lucene.Net.Search.CollectionStatistics%2CLucene.Net.Search.TermStatistics)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L554">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_IdfExplain_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.IdfExplain*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_IdfExplain_Lucene_Net_Search_CollectionStatistics_Lucene_Net_Search_TermStatistics_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.IdfExplain(Lucene.Net.Search.CollectionStatistics,Lucene.Net.Search.TermStatistics)">IdfExplain(CollectionStatistics, TermStatistics)</h4>
<div class="markdown level1 summary"><p>Computes a score factor for a simple term and returns an explanation
for that score factor.</p>
<p><p>
The default implementation uses:</p>
<pre><code>Idf(docFreq, searcher.MaxDoc);</code></pre>
<p>Note that <a class="xref" href="Lucene.Net.Search.CollectionStatistics.html#Lucene_Net_Search_CollectionStatistics_MaxDoc">MaxDoc</a> is used instead of
<a class="xref" href="Lucene.Net.Index.IndexReader.html#Lucene_Net_Index_IndexReader_NumDocs">NumDocs</a> because also
<a class="xref" href="Lucene.Net.Search.TermStatistics.html#Lucene_Net_Search_TermStatistics_DocFreq">DocFreq</a> is used, and when the latter
is inaccurate, so is <a class="xref" href="Lucene.Net.Search.CollectionStatistics.html#Lucene_Net_Search_CollectionStatistics_MaxDoc">MaxDoc</a>, and in the same direction.
In addition, <a class="xref" href="Lucene.Net.Search.CollectionStatistics.html#Lucene_Net_Search_CollectionStatistics_MaxDoc">MaxDoc</a> is more efficient to compute</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual Explanation IdfExplain(CollectionStatistics collectionStats, TermStatistics termStats)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="Lucene.Net.Search.CollectionStatistics.html">CollectionStatistics</a></td>
<td><span class="parametername">collectionStats</span></td>
<td><p>Collection-level statistics </p>
</td>
</tr>
<tr>
<td><a class="xref" href="Lucene.Net.Search.TermStatistics.html">TermStatistics</a></td>
<td><span class="parametername">termStats</span></td>
<td><p>Term-level statistics for the term </p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="Lucene.Net.Search.Explanation.html">Explanation</a></td>
<td><p>An Explain object that includes both an idf score factor
and an explanation for the term. </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_IdfExplain_Lucene_Net_Search_CollectionStatistics_Lucene_Net_Search_TermStatistics___.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.IdfExplain(Lucene.Net.Search.CollectionStatistics%2CLucene.Net.Search.TermStatistics%5B%5D)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L574">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_IdfExplain_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.IdfExplain*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_IdfExplain_Lucene_Net_Search_CollectionStatistics_Lucene_Net_Search_TermStatistics___" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.IdfExplain(Lucene.Net.Search.CollectionStatistics,Lucene.Net.Search.TermStatistics[])">IdfExplain(CollectionStatistics, TermStatistics[])</h4>
<div class="markdown level1 summary"><p>Computes a score factor for a phrase.</p>
<p><p>
The default implementation sums the idf factor for
each term in the phrase.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual Explanation IdfExplain(CollectionStatistics collectionStats, TermStatistics[] termStats)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="Lucene.Net.Search.CollectionStatistics.html">CollectionStatistics</a></td>
<td><span class="parametername">collectionStats</span></td>
<td><p>Collection-level statistics </p>
</td>
</tr>
<tr>
<td><a class="xref" href="Lucene.Net.Search.TermStatistics.html">TermStatistics</a>[]</td>
<td><span class="parametername">termStats</span></td>
<td><p>Term-level statistics for the terms in the phrase </p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="Lucene.Net.Search.Explanation.html">Explanation</a></td>
<td><p>An Explain object that includes both an idf
score factor for the phrase and an explanation
for each term. </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_LengthNorm_Lucene_Net_Index_FieldInvertState_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.LengthNorm(Lucene.Net.Index.FieldInvertState)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L614">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_LengthNorm_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.LengthNorm*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_LengthNorm_Lucene_Net_Index_FieldInvertState_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.LengthNorm(Lucene.Net.Index.FieldInvertState)">LengthNorm(FieldInvertState)</h4>
<div class="markdown level1 summary"><p>Compute an index-time normalization value for this field instance.
<p>
This value will be stored in a single byte lossy representation by
<a class="xref" href="Lucene.Net.Search.Similarities.TFIDFSimilarity.html#Lucene_Net_Search_Similarities_TFIDFSimilarity_EncodeNormValue_System_Single_">EncodeNormValue(Single)</a>.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public abstract float LengthNorm(FieldInvertState state)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="Lucene.Net.Index.FieldInvertState.html">FieldInvertState</a></td>
<td><span class="parametername">state</span></td>
<td><p>Statistics of the current field (such as length, boost, etc) </p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Single</span></td>
<td><p>An index-time normalization value </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_QueryNorm_System_Single_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.QueryNorm(System.Single)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L516">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_QueryNorm_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.QueryNorm*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_QueryNorm_System_Single_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.QueryNorm(System.Single)">QueryNorm(Single)</h4>
<div class="markdown level1 summary"><p>Computes the normalization value for a query given the sum of the squared
weights of each of the query terms. this value is multiplied into the
weight of each query term. While the classic query normalization factor is
computed as 1/sqrt(sumOfSquaredWeights), other implementations might
completely ignore sumOfSquaredWeights (ie return 1).</p>
<p><p>This does not affect ranking, but the default implementation does make scores
from different queries more comparable than they would be by eliminating the
magnitude of the <a class="xref" href="Lucene.Net.Search.Query.html">Query</a> vector as a factor in the score.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public abstract override float QueryNorm(float sumOfSquaredWeights)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Single</span></td>
<td><span class="parametername">sumOfSquaredWeights</span></td>
<td><p>The sum of the squares of query term weights </p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Single</span></td>
<td><p>A normalization factor for query weights </p>
</td>
</tr>
</tbody>
</table>
<h5 class="overrides">Overrides</h5>
<div><a class="xref" href="Lucene.Net.Search.Similarities.Similarity.html#Lucene_Net_Search_Similarities_Similarity_QueryNorm_System_Single_">Similarity.QueryNorm(Single)</a></div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_ScorePayload_System_Int32_System_Int32_System_Int32_Lucene_Net_Util_BytesRef_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.ScorePayload(System.Int32%2CSystem.Int32%2CSystem.Int32%2CLucene.Net.Util.BytesRef)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L657">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_ScorePayload_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.ScorePayload*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_ScorePayload_System_Int32_System_Int32_System_Int32_Lucene_Net_Util_BytesRef_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.ScorePayload(System.Int32,System.Int32,System.Int32,Lucene.Net.Util.BytesRef)">ScorePayload(Int32, Int32, Int32, BytesRef)</h4>
<div class="markdown level1 summary"><p>Calculate a scoring factor based on the data in the payload. Implementations
are responsible for interpreting what is in the payload. Lucene makes no assumptions about
what is in the byte array.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public abstract float ScorePayload(int doc, int start, int end, BytesRef payload)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><span class="parametername">doc</span></td>
<td><p>The docId currently being scored. </p>
</td>
</tr>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><span class="parametername">start</span></td>
<td><p>The start position of the payload </p>
</td>
</tr>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><span class="parametername">end</span></td>
<td><p>The end position of the payload </p>
</td>
</tr>
<tr>
<td><a class="xref" href="Lucene.Net.Util.BytesRef.html">BytesRef</a></td>
<td><span class="parametername">payload</span></td>
<td><p>The payload byte array to be scored </p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Single</span></td>
<td><p>An implementation dependent float to be used as a scoring factor </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_SloppyFreq_System_Int32_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.SloppyFreq(System.Int32)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L645">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_SloppyFreq_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.SloppyFreq*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_SloppyFreq_System_Int32_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.SloppyFreq(System.Int32)">SloppyFreq(Int32)</h4>
<div class="markdown level1 summary"><p>Computes the amount of a sloppy phrase match, based on an edit distance.
this value is summed for each sloppy phrase match in a document to form
the frequency to be used in scoring instead of the exact term count.</p>
<p><p>A phrase match with a small edit distance to a document passage more
closely matches the document, so implementations of this method usually
return larger values when the edit distance is small and smaller values
when it is large.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public abstract float SloppyFreq(int distance)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><span class="parametername">distance</span></td>
<td><p>The edit distance of this sloppy phrase match </p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Single</span></td>
<td><p>The frequency increment for this match </p>
</td>
</tr>
</tbody>
</table>
<h5 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_SloppyFreq_System_Int32__seealso">See Also</h5>
<div class="seealso">
<div><a class="xref" href="Lucene.Net.Search.PhraseQuery.html#Lucene_Net_Search_PhraseQuery_Slop">Slop</a></div>
</div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity_Tf_System_Single_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity.Tf(System.Single)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L531">View Source</a>
</span>
<a id="Lucene_Net_Search_Similarities_TFIDFSimilarity_Tf_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.Tf*"></a>
<h4 id="Lucene_Net_Search_Similarities_TFIDFSimilarity_Tf_System_Single_" data-uid="Lucene.Net.Search.Similarities.TFIDFSimilarity.Tf(System.Single)">Tf(Single)</h4>
<div class="markdown level1 summary"><p>Computes a score factor based on a term or phrase&apos;s frequency in a
document. This value is multiplied by the <a class="xref" href="Lucene.Net.Search.Similarities.TFIDFSimilarity.html#Lucene_Net_Search_Similarities_TFIDFSimilarity_Idf_System_Int64_System_Int64_">Idf(Int64, Int64)</a>
factor for each term in the query and these products are then summed to
form the initial score for a document.</p>
<p><p>Terms and phrases repeated in a document indicate the topic of the
document, so implementations of this method usually return larger values
when <code data-dev-comment-type="paramref" class="paramref">freq</code> is large, and smaller values when <code data-dev-comment-type="paramref" class="paramref">freq</code>
is small.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public abstract float Tf(float freq)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Single</span></td>
<td><span class="parametername">freq</span></td>
<td><p>The frequency of a term within a document </p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Single</span></td>
<td><p>A score factor based on a term&apos;s within-document frequency </p>
</td>
</tr>
</tbody>
</table>
<h3 id="seealso">See Also</h3>
<div class="seealso">
<div><a class="xref" href="Lucene.Net.Index.IndexWriterConfig.html#Lucene_Net_Index_IndexWriterConfig_Similarity">Similarity</a></div>
<div><a class="xref" href="Lucene.Net.Search.IndexSearcher.html#Lucene_Net_Search_IndexSearcher_Similarity">Similarity</a></div>
</div>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<div class="contribution">
<ul class="nav">
<li>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00013/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_Similarities_TFIDFSimilarity.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.Similarities.TFIDFSimilarity%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a>
</li>
<li>
<a href="https://github.com/apache/lucenenet/blob/fix/apidocs-layout/src/Lucene.Net/Search/Similarities/TFIDFSimilarity.cs/#L479" class="contribution-link">View Source</a>
</li>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
Copyright © 2020 The Apache Software Foundation, Licensed under the <a href='http://www.apache.org/licenses/LICENSE-2.0' target='_blank'>Apache License, Version 2.0</a><br> <small>Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation. <br>All other marks mentioned may be trademarks or registered trademarks of their respective owners.</small>
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.vendor.js"></script>
<script type="text/javascript" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.js"></script>
<script type="text/javascript" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/main.js"></script>
</body>
</html>