Examples of PossibilityIterator


Examples of org.apache.solr.spelling.PossibilityIterator

    lotsaSuggestions.put(new Token("CEE4", 0, 3), CEE);
  }

  @Test
  public void testScalability() throws Exception {
    PossibilityIterator iter = new PossibilityIterator(lotsaSuggestions, 1000, 10000);
    int count = 0;
    while (iter.hasNext()) {     
      RankedSpellPossibility rsp = iter.next();
      count++;
    }
    assertTrue(count==1000);
  }
View Full Code Here

Examples of org.apache.solr.spelling.PossibilityIterator

    assertTrue(count==1000);
  }
 
  @Test
  public void testSpellPossibilityIterator() throws Exception {
    PossibilityIterator iter = new PossibilityIterator(suggestions, 1000, 10000);
    int count = 0;
    while (iter.hasNext()) {
     
      RankedSpellPossibility rsp = iter.next();
      if(count==0) {
        assertTrue("I".equals(rsp.getCorrections().get(0).getCorrection()));
        assertTrue("alpha".equals(rsp.getCorrections().get(1).getCorrection()));
        assertTrue("one".equals(rsp.getCorrections().get(2).getCorrection()));
      }
      count++;
    }
    assertTrue(("Three maps (8*9*10) should return 720 iterations but instead returned " + count), count == 720);

    suggestions.remove(new Token("CEE", 0, 2));
    iter = new PossibilityIterator(suggestions, 100, 10000);
    count = 0;
    while (iter.hasNext()) {
      iter.next();
      count++;
    }
    assertTrue(("Two maps (8*9) should return 72 iterations but instead returned " + count), count == 72);

    suggestions.remove(new Token("BEE", 0, 2));
    iter = new PossibilityIterator(suggestions, 5, 10000);
    count = 0;
    while (iter.hasNext()) {
      iter.next();
      count++;
    }
    assertTrue(("We requested 5 suggestions but got " + count), count == 5);

    suggestions.remove(new Token("AYE", 0, 2));
    iter = new PossibilityIterator(suggestions, Integer.MAX_VALUE, 10000);
    count = 0;
    while (iter.hasNext()) {
      iter.next();
      count++;
    }
    assertTrue(("No maps should return 0 iterations but instead returned " + count), count == 0);

  }
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.