1 package org.apache.lucene.search; 2 3 18 19 20 public class DefaultSimilarity extends Similarity { 21 22 public float lengthNorm(String fieldName, int numTerms) { 23 return (float)(1.0 / Math.sqrt(numTerms)); 24 } 25 26 27 public float queryNorm(float sumOfSquaredWeights) { 28 return (float)(1.0 / Math.sqrt(sumOfSquaredWeights)); 29 } 30 31 32 public float tf(float freq) { 33 return (float)Math.sqrt(freq); 34 } 35 36 37 public float sloppyFreq(int distance) { 38 return 1.0f / (distance + 1); 39 } 40 41 42 public float idf(int docFreq, int numDocs) { 43 return (float)(Math.log(numDocs/(double)(docFreq+1)) + 1.0); 44 } 45 46 47 public float coord(int overlap, int maxOverlap) { 48 return overlap / (float)maxOverlap; 49 } 50 } 51 | Popular Tags |