Examples of InputArrayIterator


Examples of org.apache.lucene.search.suggest.InputArrayIterator

        new Input("boo foo bar foo bee", 20)
    );

    Analyzer a = new MockAnalyzer(random());
    FreeTextSuggester sug = new FreeTextSuggester(a, a, 2, (byte) 0x20);
    sug.build(new InputArrayIterator(keys));

    for(int i=0;i<2;i++) {

      // Uses bigram model and unigram backoff:
      assertEquals("foo bar/0.67 foo bee/0.33 baz/0.04 blah/0.04 boo/0.04",
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

    Iterable<Input> keys = shuffle(
        new Input("foo\u001ebar baz", 50)
    );
    FreeTextSuggester sug = new FreeTextSuggester(new MockAnalyzer(random()));
    try {
      sug.build(new InputArrayIterator(keys));
      fail("did not hit expected exception");
    } catch (IllegalArgumentException iae) {
      // expected
    }
  }
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

    // (0x1e), so no input token is allowed to contain it
    Iterable<Input> keys = shuffle(
        new Input("foo bar baz", 50)
    );
    FreeTextSuggester sug = new FreeTextSuggester(new MockAnalyzer(random()));
    sug.build(new InputArrayIterator(keys));

    try {
      sug.lookup("foo\u001eb", 10);
      fail("did not hit expected exception");
    } catch (IllegalArgumentException iae) {
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

        new Input("foo bar baz blah boo foo bar foo bee", 50)
    );

    Analyzer a = new MockAnalyzer(random());
    FreeTextSuggester sug = new FreeTextSuggester(a, a, 1, (byte) 0x20);
    sug.build(new InputArrayIterator(keys));
    // Sorts first by count, descending, second by term, ascending
    assertEquals("bar/0.22 baz/0.11 bee/0.11 blah/0.11 boo/0.11",
                 toString(sug.lookup("b", 10)));
  }
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

    Iterable<Input> keys = shuffle(
        new Input("foo bar bar bar bar", 50)
    );
    Analyzer a = new MockAnalyzer(random());
    FreeTextSuggester sug = new FreeTextSuggester(a, a, 2, (byte) 0x20);
    sug.build(new InputArrayIterator(keys));
    assertEquals("foo bar/1.00",
                 toString(sug.lookup("foo b", 10)));
  }
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

    Iterable<Input> keys = shuffle(
        new Input("foo bar bar bar bar", 50)
    );
    Analyzer a = new MockAnalyzer(random());
    FreeTextSuggester sug = new FreeTextSuggester(a, a, 2, (byte) 0x20);
    sug.build(new InputArrayIterator(keys));
    try {
      sug.lookup("", 10);
      fail("did not hit exception");
    } catch (IllegalArgumentException iae) {
      // expected
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

    Iterable<Input> keys = shuffle(
        new Input("wizard of oz", 50)
    );
    FreeTextSuggester sug = new FreeTextSuggester(a, a, 3, (byte) 0x20);
    sug.build(new InputArrayIterator(keys));
    assertEquals("wizard _ oz/1.00",
                 toString(sug.lookup("wizard of", 10)));

    // Falls back to unigram model, with backoff 0.4 times
    // prop 0.5:
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

    Iterable<Input> keys = shuffle(
        new Input("wizard of of oz", 50)
    );
    FreeTextSuggester sug = new FreeTextSuggester(a, a, 3, (byte) 0x20);
    sug.build(new InputArrayIterator(keys));
    assertEquals("",
                 toString(sug.lookup("wizard of of", 10)));
  }
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

        new Input("barbara", 6)
    };
   
    Random random = new Random(random().nextLong());
    WFSTCompletionLookup suggester = new WFSTCompletionLookup();
    suggester.build(new InputArrayIterator(keys));
   
    // top N of 2, but only foo is available
    List<LookupResult> results = suggester.lookup(_TestUtil.stringToCharSequence("f", random), false, 2);
    assertEquals(1, results.size());
    assertEquals("foo", results.get(0).key.toString());
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

  public void testExactFirst() throws Exception {

    WFSTCompletionLookup suggester = new WFSTCompletionLookup(true);

    suggester.build(new InputArrayIterator(new Input[] {
          new Input("x y", 20),
          new Input("x", 2),
        }));

    for(int topN=1;topN<4;topN++) {
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.