| java.lang.Object org.apache.lucene.search.Similarity org.apache.lucene.search.DefaultSimilarity org.apache.lucene.misc.SweetSpotSimilarity
SweetSpotSimilarity | public class SweetSpotSimilarity extends DefaultSimilarity (Code) | | A similarity with a lengthNorm that provides for a "platuea" of
equally good lengths, and tf helper functions.
For lengthNorm, A global min/max can be specified to define the
platuea 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.
A per field min/max can be specified if different fields have
different sweet spots.
For tf, baselineTf and hyperbolicTf functions are provided, which
subclasses can choose between.
|
Method Summary | |
public float | baselineTf(float freq) Implemented as:
(x <= min) ? base : sqrt(x+(base**2)-min)
...but with a special case check for 0. | public float | hyperbolicTf(float freq) Uses a hyperbolic tangent function that allows for a hard max... | public float | lengthNorm(String fieldName, int numTerms) Implemented as:
1/sqrt( steepness * (abs(x-min) + abs(x-max) - (max-min)) + 1 )
. | public void | setBaselineTfFactors(float base, float min) | public void | setHyperbolicTfFactors(float min, float max, double base, float xoffset) | public void | setLengthNormFactors(int min, int max, float steepness) Sets the default function variables used by lengthNorm when no field
specifc variables have been set. | public void | setLengthNormFactors(String field, int min, int max, float steepness) | public float | tf(int freq) |
SweetSpotSimilarity | public SweetSpotSimilarity()(Code) | | |
baselineTf | public float baselineTf(float freq)(Code) | | Implemented as:
(x <= min) ? base : sqrt(x+(base**2)-min)
...but with a special case check for 0.
This degrates to sqrt(x) when min and base are both 0
See Also: SweetSpotSimilarity.setBaselineTfFactors |
hyperbolicTf | public float hyperbolicTf(float freq)(Code) | | 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 convincience for subclasses that want
to use a hyperbolic tf function.
See Also: SweetSpotSimilarity.setHyperbolicTfFactors |
lengthNorm | public float lengthNorm(String fieldName, int numTerms)(Code) | | Implemented as:
1/sqrt( steepness * (abs(x-min) + abs(x-max) - (max-min)) + 1 )
.
This degrades to 1/sqrt(x) when min and max are both 1 and
steepness is 0.5
:TODO: potential optimiation is to just flat out return 1.0f if numTerms
is between min and max.
See Also: SweetSpotSimilarity.setLengthNormFactors |
setBaselineTfFactors | public void setBaselineTfFactors(float base, float min)(Code) | | Sets the baseline and minimum function variables for baselineTf
See Also: SweetSpotSimilarity.baselineTf |
setHyperbolicTfFactors | public void setHyperbolicTfFactors(float min, float max, double base, float xoffset)(Code) | | Sets the function variables for the hyperbolicTf functions
Parameters: min - the minimum tf value to ever be returned (default: 0.0) Parameters: max - the maximum tf value to ever be returned (default: 2.0) Parameters: base - the base value to be used in the exponential for the hyperbolic function (default: e) Parameters: xoffset - the midpoint of the hyperbolic function (default: 10.0) See Also: SweetSpotSimilarity.hyperbolicTf |
setLengthNormFactors | public void setLengthNormFactors(int min, int max, float steepness)(Code) | | Sets the default function variables used by lengthNorm when no field
specifc variables have been set.
See Also: SweetSpotSimilarity.lengthNorm |
setLengthNormFactors | public void setLengthNormFactors(String field, int min, int max, float steepness)(Code) | | Sets the function variables used by lengthNorm for a specific named field
See Also: SweetSpotSimilarity.lengthNorm |
|
|