Package org.apache.lucene.search.similarities

Examples of org.apache.lucene.search.similarities.DefaultSimilarity.tf()


     * Ensures output is either 1 (for all inputs > 0), or 0.
     */
    @Test
    public void testTF() {
        DefaultSimilarity sim = new BinarySimilarity();
        assertEquals("big positive number", 1, (int)Math.round(sim.tf(999)));
        assertEquals("slightly more than 1", 1, (int)Math.round(sim.tf(2)));
        assertEquals("just 1", 1, (int)Math.round(sim.tf(1)));
        assertEquals("slightly less than 1", 0, (int)Math.round(sim.tf(0)));
        assertEquals("big negative number", 0, (int)Math.round(sim.tf(-999)));
    }
View Full Code Here


     */
    @Test
    public void testTF() {
        DefaultSimilarity sim = new BinarySimilarity();
        assertEquals("big positive number", 1, (int)Math.round(sim.tf(999)));
        assertEquals("slightly more than 1", 1, (int)Math.round(sim.tf(2)));
        assertEquals("just 1", 1, (int)Math.round(sim.tf(1)));
        assertEquals("slightly less than 1", 0, (int)Math.round(sim.tf(0)));
        assertEquals("big negative number", 0, (int)Math.round(sim.tf(-999)));
    }

View Full Code Here

    @Test
    public void testTF() {
        DefaultSimilarity sim = new BinarySimilarity();
        assertEquals("big positive number", 1, (int)Math.round(sim.tf(999)));
        assertEquals("slightly more than 1", 1, (int)Math.round(sim.tf(2)));
        assertEquals("just 1", 1, (int)Math.round(sim.tf(1)));
        assertEquals("slightly less than 1", 0, (int)Math.round(sim.tf(0)));
        assertEquals("big negative number", 0, (int)Math.round(sim.tf(-999)));
    }

}
View Full Code Here

    public void testTF() {
        DefaultSimilarity sim = new BinarySimilarity();
        assertEquals("big positive number", 1, (int)Math.round(sim.tf(999)));
        assertEquals("slightly more than 1", 1, (int)Math.round(sim.tf(2)));
        assertEquals("just 1", 1, (int)Math.round(sim.tf(1)));
        assertEquals("slightly less than 1", 0, (int)Math.round(sim.tf(0)));
        assertEquals("big negative number", 0, (int)Math.round(sim.tf(-999)));
    }

}
View Full Code Here

        DefaultSimilarity sim = new BinarySimilarity();
        assertEquals("big positive number", 1, (int)Math.round(sim.tf(999)));
        assertEquals("slightly more than 1", 1, (int)Math.round(sim.tf(2)));
        assertEquals("just 1", 1, (int)Math.round(sim.tf(1)));
        assertEquals("slightly less than 1", 0, (int)Math.round(sim.tf(0)));
        assertEquals("big negative number", 0, (int)Math.round(sim.tf(-999)));
    }

}
View Full Code Here

    ss.setBaselineTfFactors(0.0f, 0.0f);
 
    for (int i = 1; i < 1000; i++) {
      assertEquals("tf: i="+i,
                   d.tf(i), s.tf(i), 0.0f);
    }

    // tf higher
 
    ss.setBaselineTfFactors(1.0f, 0.0f);
View Full Code Here

    // tf higher
 
    ss.setBaselineTfFactors(1.0f, 0.0f);
 
    for (int i = 1; i < 1000; i++) {
      assertTrue("tf: i="+i+" : d="+d.tf(i)+
                 " < s="+s.tf(i),
                 d.tf(i) < s.tf(i));
    }

    // tf flat
View Full Code Here

    ss.setBaselineTfFactors(1.0f, 0.0f);
 
    for (int i = 1; i < 1000; i++) {
      assertTrue("tf: i="+i+" : d="+d.tf(i)+
                 " < s="+s.tf(i),
                 d.tf(i) < s.tf(i));
    }

    // tf flat
 
    ss.setBaselineTfFactors(1.0f, 6.0f);
View Full Code Here

    for (int i = 1; i <=6; i++) {
      assertEquals("tf flat2: i="+i, 2.0f, s.tf(i), 0.0f);
    }
    for (int i = 6; i <=1000; i++) {
      assertTrue("tf: i="+i+" : s="+s.tf(i)+
                 " < d="+d.tf(i),
                 s.tf(i) < d.tf(i));
    }

    // stupidity
    assertEquals("tf zero", 0.0f, s.tf(0), 0.0f);
View Full Code Here

      assertEquals("tf flat2: i="+i, 2.0f, s.tf(i), 0.0f);
    }
    for (int i = 6; i <=1000; i++) {
      assertTrue("tf: i="+i+" : s="+s.tf(i)+
                 " < d="+d.tf(i),
                 s.tf(i) < d.tf(i));
    }

    // stupidity
    assertEquals("tf zero", 0.0f, s.tf(0), 0.0f);
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.