Examples of Input


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

@SuppressCodecs("Lucene3x")
public class TestFreeTextSuggester extends LuceneTestCase {

  public void testBasic() throws Exception {
    Iterable<Input> keys = shuffle(
        new Input("foo bar baz blah", 50),
        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));
View Full Code Here

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

  public void testIllegalByteDuringBuild() throws Exception {
    // Default separator is INFORMATION SEPARATOR TWO
    // (0x1e), so no input token is allowed to contain it
    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");
View Full Code Here

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

  public void testIllegalByteDuringQuery() throws Exception {
    // Default separator is INFORMATION SEPARATOR TWO
    // (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 {
View Full Code Here

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

  }

  // Make sure you can suggest based only on unigram model:
  public void testUnigrams() throws Exception {
    Iterable<Input> keys = shuffle(
        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));
View Full Code Here

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

  }

  // Make sure the last token is not duplicated
  public void testNoDupsAcrossGrams() throws Exception {
    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",
View Full Code Here

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

  }

  // Lookup of just empty string produces unicode only matches:
  public void testEmptyString() throws Exception {
    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 {
View Full Code Here

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

          return new TokenStreamComponents(tokenizer, new StopFilter(TEST_VERSION_CURRENT, tokenizer, stopSet));
        }
      };

    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)));
View Full Code Here

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

          return new TokenStreamComponents(tokenizer, new StopFilter(TEST_VERSION_CURRENT, tokenizer, stopSet));
        }
      };

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

import org.apache.lucene.util._TestUtil;

public class WFSTCompletionTest extends LuceneTestCase {
 
  public void testBasic() throws Exception {
    Input keys[] = new Input[] {
        new Input("foo", 50),
        new Input("bar", 10),
        new Input("barbar", 12),
        new Input("barbara", 6)
    };
   
    Random random = new Random(random().nextLong());
    WFSTCompletionLookup suggester = new WFSTCompletionLookup();
    suggester.build(new InputArrayIterator(keys));
View Full Code Here

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

  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++) {
      List<LookupResult> results = suggester.lookup("x", false, 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.