Show / Hide Table of Contents

    Class SweetSpotSimilarity

    A similarity with a lengthNorm that provides for a "plateau" of equally good lengths, and tf helper functions.

    For lengthNorm, A min/max can be specified to define the plateau of lengths that should all have a norm of 1.0. Below the min, and above the max the lengthNorm drops off in a sqrt function.

    For tf, baselineTf and hyperbolicTf functions are provided, which subclasses can choose between.

    Inheritance
    System.Object
    Similarity
    TFIDFSimilarity
    DefaultSimilarity
    SweetSpotSimilarity
    Inherited Members
    DefaultSimilarity.Coord(Int32, Int32)
    DefaultSimilarity.QueryNorm(Single)
    DefaultSimilarity.EncodeNormValue(Single)
    DefaultSimilarity.DecodeNormValue(Int64)
    DefaultSimilarity.SloppyFreq(Int32)
    DefaultSimilarity.ScorePayload(Int32, Int32, Int32, BytesRef)
    DefaultSimilarity.Idf(Int64, Int64)
    DefaultSimilarity.m_discountOverlaps
    DefaultSimilarity.DiscountOverlaps
    DefaultSimilarity.ToString()
    TFIDFSimilarity.IdfExplain(CollectionStatistics, TermStatistics)
    TFIDFSimilarity.IdfExplain(CollectionStatistics, TermStatistics[])
    TFIDFSimilarity.ComputeNorm(FieldInvertState)
    TFIDFSimilarity.ComputeWeight(Single, CollectionStatistics, TermStatistics[])
    TFIDFSimilarity.GetSimScorer(Similarity.SimWeight, AtomicReaderContext)
    Namespace: Lucene.Net.Misc
    Assembly: Lucene.Net.Misc.dll
    Syntax
    public class SweetSpotSimilarity : DefaultSimilarity

    Constructors

    | Improve this Doc View Source

    SweetSpotSimilarity()

    Declaration
    public SweetSpotSimilarity()

    Methods

    | Improve this Doc View Source

    BaselineTf(Single)

    Implemented as:

     (x <= min) ? base : Math.Sqrt(x+(base**2)-min)

    ...but with a special case check for 0.

    This degrates to

    Math.Sqrt(x)
    when min and base are both 0

    Declaration
    public virtual float BaselineTf(float freq)
    Parameters
    Type Name Description
    System.Single freq
    Returns
    Type Description
    System.Single
    See Also
    SetBaselineTfFactors(Single, Single)
    | Improve this Doc View Source

    ComputeLengthNorm(Int32)

    Implemented as:

    1/sqrt( steepness * (Math.Abs(x-min) + Math.Abs(x-max) - (max-min)) + 1 )
    .

    This degrades to

    1/Math.Sqrt(x)
    when min and max are both 1 and steepness is 0.5

    :TODO: potential optimization is to just flat out return 1.0f if numTerms is between min and max.

    Declaration
    public virtual float ComputeLengthNorm(int numTerms)
    Parameters
    Type Name Description
    System.Int32 numTerms
    Returns
    Type Description
    System.Single
    See Also
    SetLengthNormFactors(Int32, Int32, Single, Boolean)
    | Improve this Doc View Source

    HyperbolicTf(Single)

    Uses a hyperbolic tangent function that allows for a hard max...

    tf(x)=min+(max-min)/2*(((base**(x-xoffset)-base**-(x-xoffset))/(base**(x-xoffset)+base**-(x-xoffset)))+1)

    This code is provided as a convenience for subclasses that want to use a hyperbolic tf function.

    Declaration
    public virtual float HyperbolicTf(float freq)
    Parameters
    Type Name Description
    System.Single freq
    Returns
    Type Description
    System.Single
    See Also
    SetHyperbolicTfFactors(Single, Single, Double, Single)
    | Improve this Doc View Source

    LengthNorm(FieldInvertState)

    Implemented as state.Boost * ComputeLengthNorm(numTokens) where numTokens does not count overlap tokens if discountOverlaps is true by default or true for this specific field.

    Declaration
    public override float LengthNorm(FieldInvertState state)
    Parameters
    Type Name Description
    FieldInvertState state
    Returns
    Type Description
    System.Single
    Overrides
    DefaultSimilarity.LengthNorm(FieldInvertState)
    | Improve this Doc View Source

    SetBaselineTfFactors(Single, Single)

    Sets the baseline and minimum function variables for baselineTf

    Declaration
    public virtual void SetBaselineTfFactors(float base, float min)
    Parameters
    Type Name Description
    System.Single base
    System.Single min
    See Also
    BaselineTf(Single)
    | Improve this Doc View Source

    SetHyperbolicTfFactors(Single, Single, Double, Single)

    Sets the function variables for the hyperbolicTf functions

    Declaration
    public virtual void SetHyperbolicTfFactors(float min, float max, double base, float xoffset)
    Parameters
    Type Name Description
    System.Single min

    the minimum tf value to ever be returned (default: 0.0)

    System.Single max

    the maximum tf value to ever be returned (default: 2.0)

    System.Double base

    the base value to be used in the exponential for the hyperbolic function (default: 1.3)

    System.Single xoffset

    the midpoint of the hyperbolic function (default: 10.0)

    See Also
    HyperbolicTf(Single)
    | Improve this Doc View Source

    SetLengthNormFactors(Int32, Int32, Single, Boolean)

    Sets the default function variables used by lengthNorm when no field specific variables have been set.

    Declaration
    public virtual void SetLengthNormFactors(int min, int max, float steepness, bool discountOverlaps)
    Parameters
    Type Name Description
    System.Int32 min
    System.Int32 max
    System.Single steepness
    System.Boolean discountOverlaps
    See Also
    ComputeLengthNorm(Int32)
    | Improve this Doc View Source

    Tf(Single)

    Delegates to baselineTf

    Declaration
    public override float Tf(float freq)
    Parameters
    Type Name Description
    System.Single freq
    Returns
    Type Description
    System.Single
    See Also
    BaselineTf(Single)
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)