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
Inherited Members
Namespace: Lucene.Net.Misc
Assembly: Lucene.Net.Misc.dll
Syntax
public class SweetSpotSimilarity : DefaultSimilarity
Constructors
| Improve this Doc View SourceSweetSpotSimilarity()
Declaration
public SweetSpotSimilarity()
Methods
| Improve this Doc View SourceBaselineTf(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
| Improve this Doc View SourceComputeLengthNorm(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
| Improve this Doc View SourceHyperbolicTf(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
| Improve this Doc View SourceLengthNorm(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 |
---|---|---|
Lucene.Net.Index.FieldInvertState | state |
Returns
Type | Description |
---|---|
System.Single |
Overrides
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
| Improve this Doc View SourceSetHyperbolicTfFactors(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
| Improve this Doc View SourceSetLengthNormFactors(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
| Improve this Doc View SourceTf(Single)
Delegates to baselineTf
Declaration
public override float Tf(float freq)
Parameters
Type | Name | Description |
---|---|---|
System.Single | freq |
Returns
Type | Description |
---|---|
System.Single |