Package org.apache.lucene.search.suggest

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


public class AnalyzingSuggesterTest extends LuceneTestCase {
 
  /** this is basically the WFST test ported to KeywordAnalyzer. so it acts the same */
  public void testKeyword() throws Exception {
    TermFreq keys[] = new TermFreq[] {
        new TermFreq("foo", 50),
        new TermFreq("bar", 10),
        new TermFreq("barbar", 12),
        new TermFreq("barbara", 6)
    };
   
    AnalyzingSuggester suggester = new AnalyzingSuggester(new MockAnalyzer(random(), MockTokenizer.KEYWORD, false));
    suggester.build(new TermFreqArrayIterator(keys));
   
View Full Code Here


  // TODO: more tests
  /**
   * basic "standardanalyzer" test with stopword removal
   */
  public void testStandard() throws Exception {
    TermFreq keys[] = new TermFreq[] {
        new TermFreq("the ghost of christmas past", 50),
    };
   
    Analyzer standard = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, true, MockTokenFilter.ENGLISH_STOPSET);
    AnalyzingSuggester suggester = new AnalyzingSuggester(standard);
    suggester.setPreservePositionIncrements(false);
View Full Code Here

    assertTrue(result.isEmpty());
  }

  public void testNoSeps() throws Exception {
    TermFreq[] keys = new TermFreq[] {
      new TermFreq("ab cd", 0),
      new TermFreq("abcd", 1),
    };

    int options = 0;

    Analyzer a = new MockAnalyzer(random());
View Full Code Here

          }
        };
      }
    };

    TermFreq keys[] = new TermFreq[] {
        new TermFreq("wifi network is slow", 50),
        new TermFreq("wi fi network is fast", 10),
    };
    //AnalyzingSuggester suggester = new AnalyzingSuggester(analyzer, AnalyzingSuggester.EXACT_FIRST, 256, -1);
    AnalyzingSuggester suggester = new AnalyzingSuggester(analyzer);
    suggester.build(new TermFreqArrayIterator(keys));
    List<LookupResult> results = suggester.lookup("wifi network", false, 10);
View Full Code Here

          }
        };
      }
    };

    TermFreq keys[] = new TermFreq[] {
        new TermFreq("ab xc", 50),
        new TermFreq("ba xd", 50),
    };
    AnalyzingSuggester suggester = new AnalyzingSuggester(analyzer);
    suggester.build(new TermFreqArrayIterator(keys));
    List<LookupResult> results = suggester.lookup("ab x", false, 1);
    assertTrue(results.size() == 1);
View Full Code Here

  public void testExactFirst() throws Exception {

    Analyzer a = getUnusualAnalyzer();
    AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, AnalyzingSuggester.EXACT_FIRST | AnalyzingSuggester.PRESERVE_SEP, 256, -1);
    suggester.build(new TermFreqArrayIterator(new TermFreq[] {
          new TermFreq("x y", 1),
          new TermFreq("x y z", 3),
          new TermFreq("x", 2),
          new TermFreq("z z z", 20),
        }));

    //System.out.println("ALL: " + suggester.lookup("x y", false, 6));

    for(int topN=1;topN<6;topN++) {
View Full Code Here

    Analyzer a = getUnusualAnalyzer();
    AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, AnalyzingSuggester.PRESERVE_SEP, 256, -1);

    suggester.build(new TermFreqArrayIterator(new TermFreq[] {
          new TermFreq("x y", 1),
          new TermFreq("x y z", 3),
          new TermFreq("x", 2),
          new TermFreq("z z z", 20),
        }));

    for(int topN=1;topN<6;topN++) {
      List<LookupResult> results = suggester.lookup("p", false, topN);
View Full Code Here

        byte[] bytes = new byte[random().nextInt(10)];
        random().nextBytes(bytes);
        payload = new BytesRef(bytes);
        payloadKeys[i] = new TermFreqPayload(key, weight, payload);
      } else {
        keys[i] = new TermFreq(key, weight);
        payload = null;
      }

      slowCompletor.add(new TermFreq2(key, analyzedKey, weight, payload));
    }
View Full Code Here

              }
            };
          }
        };

      TermFreq keys[] = new TermFreq[] {
        new TermFreq("a a", 50),
        new TermFreq("a b", 50),
      };

      AnalyzingSuggester suggester = new AnalyzingSuggester(analyzer, analyzer, AnalyzingSuggester.EXACT_FIRST | (i==0 ? AnalyzingSuggester.PRESERVE_SEP : 0), 256, -1);
      suggester.build(new TermFreqArrayIterator(keys));
      List<LookupResult> results = suggester.lookup("a a", false, 5);
View Full Code Here

  public void testMaxSurfaceFormsPerAnalyzedForm() throws Exception {
    Analyzer a = new MockAnalyzer(random());
    AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, 0, 2, -1);

    List<TermFreq> keys = Arrays.asList(new TermFreq[] {
        new TermFreq("a", 40),
        new TermFreq("a ", 50),
        new TermFreq(" a", 60),
      });

    Collections.shuffle(keys, random());
    suggester.build(new TermFreqArrayIterator(keys));
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.suggest.TermFreq

Copyright © 2018 www.massapicom. 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.