org.ow2.weblab.services.duplicates
Class CustomSimilarity

java.lang.Object
  extended by org.apache.lucene.search.Similarity
      extended by org.ow2.weblab.services.duplicates.CustomSimilarity
All Implemented Interfaces:
java.io.Serializable

public class CustomSimilarity
extends org.apache.lucene.search.Similarity

Expert: Default scoring implementation.

See Also:
Serialized Form

Field Summary
protected  boolean discountOverlaps
           
 
Fields inherited from class org.apache.lucene.search.Similarity
NO_DOC_ID_PROVIDED
 
Constructor Summary
CustomSimilarity()
           
 
Method Summary
 float computeNorm(java.lang.String field, org.apache.lucene.index.FieldInvertState state)
          Implemented as state.getBoost()*lengthNorm(numTerms), where numTerms is FieldInvertState.getLength() if setDiscountOverlaps(boolean) is false, else it's FieldInvertState.getLength() - FieldInvertState.getNumOverlap().
 float coord(int overlap, int maxOverlap)
          Implemented as overlap / maxOverlap.
 boolean getDiscountOverlaps()
           
 float idf(int docFreq, int numDocs)
          Implemented as log(numDocs/(docFreq+1)) + 1.
 float lengthNorm(java.lang.String fieldName, int numTerms)
          Implemented as 1/sqrt(numTerms).
 float queryNorm(float sumOfSquaredWeights)
          Implemented as 1/sqrt(sumOfSquaredWeights).
 void setDiscountOverlaps(boolean v)
          Determines whether overlap tokens (Tokens with 0 position increment) are ignored when computing norm.
 float sloppyFreq(int distance)
          Implemented as 1 / (distance + 1).
 float tf(float freq)
          Implemented as sqrt(freq).
 
Methods inherited from class org.apache.lucene.search.Similarity
decodeNorm, encodeNorm, getDefault, getNormDecoder, idf, idf, idfExplain, idfExplain, scorePayload, scorePayload, setDefault, tf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

discountOverlaps

protected boolean discountOverlaps
Constructor Detail

CustomSimilarity

public CustomSimilarity()
Method Detail

computeNorm

public float computeNorm(java.lang.String field,
                         org.apache.lucene.index.FieldInvertState state)
Implemented as state.getBoost()*lengthNorm(numTerms), where numTerms is FieldInvertState.getLength() if setDiscountOverlaps(boolean) is false, else it's FieldInvertState.getLength() - FieldInvertState.getNumOverlap().

WARNING: This API is new and experimental, and may suddenly change.

Overrides:
computeNorm in class org.apache.lucene.search.Similarity

lengthNorm

public float lengthNorm(java.lang.String fieldName,
                        int numTerms)
Implemented as 1/sqrt(numTerms).

Specified by:
lengthNorm in class org.apache.lucene.search.Similarity

queryNorm

public float queryNorm(float sumOfSquaredWeights)
Implemented as 1/sqrt(sumOfSquaredWeights).

Specified by:
queryNorm in class org.apache.lucene.search.Similarity

tf

public float tf(float freq)
Implemented as sqrt(freq).

Specified by:
tf in class org.apache.lucene.search.Similarity

sloppyFreq

public float sloppyFreq(int distance)
Implemented as 1 / (distance + 1).

Specified by:
sloppyFreq in class org.apache.lucene.search.Similarity

idf

public float idf(int docFreq,
                 int numDocs)
Implemented as log(numDocs/(docFreq+1)) + 1.

Specified by:
idf in class org.apache.lucene.search.Similarity

coord

public float coord(int overlap,
                   int maxOverlap)
Implemented as overlap / maxOverlap.

Specified by:
coord in class org.apache.lucene.search.Similarity

setDiscountOverlaps

public void setDiscountOverlaps(boolean v)
Determines whether overlap tokens (Tokens with 0 position increment) are ignored when computing norm. By default this is false, meaning overlap tokens are counted just like non-overlap tokens.

WARNING: This API is new and experimental, and may suddenly change.

See Also:
computeNorm(java.lang.String, org.apache.lucene.index.FieldInvertState)

getDiscountOverlaps

public boolean getDiscountOverlaps()
See Also:
setDiscountOverlaps(boolean)


Copyright © 2004-2010. All Rights Reserved.