Normalization (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.search.similarities, class: Normalization

Package org.apache.lucene.search.similarities

# Class Normalization

java.lang.Object
org.apache.lucene.search.similarities.Normalization

Direct Known Subclasses:
  `Normalization.NoNormalization`, `NormalizationH1`, `NormalizationH2`, `NormalizationH3`, `NormalizationZ`

public abstract class Normalization extends Object
This class acts as the base class for the implementations of the term frequency normalization methods in the DFR framework.

See Also:
  - `DFRSimilarity`
WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `Normalization.NoNormalization`
  Implementation used when there is no normalization.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Normalization()`
  Sole constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Explanation`
  `explain(BasicStats stats, double tf, double len)`
  Returns an explanation for the normalized term frequency.
  `abstract double`
  `tfn(BasicStats stats, double tf, double len)`
  Returns the normalized term frequency.
  `abstract String`
  `toString()`
  Subclasses must override this method to return the code of the normalization formula.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### Normalization

    public Normalization()
    Sole constructor. (For invocation by subclass constructors, typically implicit.)

- ## Method Details

  - ### tfn

    public abstract double tfn(BasicStats stats, double tf, double len)
    Returns the normalized term frequency.
    Parameters:
      `len` - the field length.

  - ### explain

    public Explanation explain(BasicStats stats, double tf, double len)
    Returns an explanation for the normalized term frequency.

    The default normalization methods use the field length of the document and the average field length to compute the normalized term frequency. This method provides a generic explanation for such methods. Subclasses that use other statistics must override this method.

  - ### toString

    public abstract String toString()
    Subclasses must override this method to return the code of the normalization formula. Refer to the original paper for the list.
    Overrides:
      `toString` in class `Object`