@Test public void testLengthNorm() { MySimilarity s = new MySimilarity(); assertEquals(0, s.lengthNorm("test", 0), 1e-6); assertEquals(0.289400, s.lengthNorm("test", 10), 1e-6); assertEquals(0.234860, s.lengthNorm("test", 19), 1e-6); assertEquals(0.223606, s.lengthNorm("test", 20), 1e-6); }
@Override public float lengthNorm(String fieldName, int numTerms) { if (numTerms < 20) { if (numTerms <= 0) return 0; return -0.00606f * numTerms + 0.35f; } return (float) (1.0 / Math.sqrt(numTerms)); }
MySimilarity extends DefaultSimilarity { @Override public float lengthNorm(String fieldName, int numTerms) { if (numTerms < 20) { if (numTerms <= 0) return 0; return -0.00606f * numTerms + 0.35f; } return (float) (1.0 / Math.sqrt(numTerms)); } }
MySimilarity extends DefaultSimilarity { @Override public float lengthNorm(String fieldName, int numTerms) { if (numTerms < 20) { if (numTerms <= 0) return 0; return -0.00606f * numTerms + 0.35f; } return (float) (1.0 / Math.sqrt(numTerms)); }  }
MySimilarity extends DefaultSimilarity { @Override public float lengthNorm(String fieldName, int numTerms) { if (numTerms < 20) { if (numTerms <= 0) return 0; return -0.00606f * numTerms + 0.35f; } return (float) (1.0 / Math.sqrt(numTerms)); }  @Override float lengthNorm(String fieldName, int numTerms); }
MySimilarity extends DefaultSimilarity { @Override public float lengthNorm(String fieldName, int numTerms) { if (numTerms < 20) { if (numTerms <= 0) return 0; return -0.00606f * numTerms + 0.35f; } return (float) (1.0 / Math.sqrt(numTerms)); }  @Override float lengthNorm(String fieldName, int numTerms);  }