|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.lucene.search.similarities.Similarity
org.apache.lucene.search.similarities.TFIDFSimilarity
org.apache.lucene.search.similarities.DefaultSimilarity
public class DefaultSimilarity
Expert: Default scoring implementation.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.apache.lucene.search.similarities.Similarity |
|---|
Similarity.ExactSimScorer, Similarity.SimWeight, Similarity.SloppySimScorer |
| Field Summary | |
|---|---|
protected boolean |
discountOverlaps
True if overlap tokens (tokens with a position of increment of zero) are discounted from the document's length. |
| Constructor Summary | |
|---|---|
DefaultSimilarity()
Sole constructor: parameter-free |
|
| Method Summary | |
|---|---|
void |
computeNorm(FieldInvertState state,
Norm norm)
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()
Returns true if overlap tokens are discounted from the document's length. |
float |
idf(long docFreq,
long numDocs)
Implemented as log(numDocs/(docFreq+1)) + 1. |
float |
queryNorm(float sumOfSquaredWeights)
Implemented as 1/sqrt(sumOfSquaredWeights). |
float |
scorePayload(int doc,
int start,
int end,
BytesRef payload)
The default implementation returns 1 |
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). |
String |
toString()
|
| Methods inherited from class org.apache.lucene.search.similarities.TFIDFSimilarity |
|---|
computeWeight, decodeNormValue, encodeNormValue, exactSimScorer, idfExplain, idfExplain, sloppySimScorer, tf |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected boolean discountOverlaps
| Constructor Detail |
|---|
public DefaultSimilarity()
| Method Detail |
|---|
public float coord(int overlap,
int maxOverlap)
overlap / maxOverlap.
coord in class TFIDFSimilarityoverlap - the number of query terms matched in the documentmaxOverlap - the total number of terms in the query
public float queryNorm(float sumOfSquaredWeights)
1/sqrt(sumOfSquaredWeights).
queryNorm in class TFIDFSimilaritysumOfSquaredWeights - the sum of the squares of query term weights
public void computeNorm(FieldInvertState state,
Norm norm)
state.getBoost()*lengthNorm(numTerms), where
numTerms is FieldInvertState.getLength() if setDiscountOverlaps(boolean) is false, else it's FieldInvertState.getLength() - FieldInvertState.getNumOverlap().
computeNorm in class Similaritystate - current processing state for this fieldnorm - holds the computed norm value when this method returnspublic float tf(float freq)
sqrt(freq).
tf in class TFIDFSimilarityfreq - the frequency of a term within a document
public float sloppyFreq(int distance)
1 / (distance + 1).
sloppyFreq in class TFIDFSimilaritydistance - the edit distance of this sloppy phrase match
PhraseQuery.setSlop(int)
public float scorePayload(int doc,
int start,
int end,
BytesRef payload)
1
scorePayload in class TFIDFSimilaritydoc - The docId currently being scored.start - The start position of the payloadend - The end position of the payloadpayload - The payload byte array to be scored
public float idf(long docFreq,
long numDocs)
log(numDocs/(docFreq+1)) + 1.
idf in class TFIDFSimilaritydocFreq - the number of documents which contain the termnumDocs - the total number of documents in the collection
public void setDiscountOverlaps(boolean v)
computeNorm(org.apache.lucene.index.FieldInvertState, org.apache.lucene.index.Norm)public boolean getDiscountOverlaps()
setDiscountOverlaps(boolean)public String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||