Search in sources :

Example 1 with NgramAnalyzer

use of com.apple.foundationdb.record.lucene.ngram.NgramAnalyzer in project fdb-record-layer by FoundationDB.

the class LuceneAnalyzerTest method testNgramAnalyzerWithStopWords.

@Test
void testNgramAnalyzerWithStopWords() throws Exception {
    final CharArraySet stopSet = new CharArraySet(List.of("hello"), false);
    CharArraySet stopWords = CharArraySet.unmodifiableSet(stopSet);
    String input = "hello RL";
    Collection<String> result = new HashSet<>();
    tokenizeWithAnalyzer(result, input, new NgramAnalyzer(stopWords, 3, 10, false));
    Assertions.assertEquals(ImmutableSet.of("rl"), result);
}
Also used : CharArraySet(org.apache.lucene.analysis.CharArraySet) NgramAnalyzer(com.apple.foundationdb.record.lucene.ngram.NgramAnalyzer) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 2 with NgramAnalyzer

use of com.apple.foundationdb.record.lucene.ngram.NgramAnalyzer in project fdb-record-layer by FoundationDB.

the class LuceneAnalyzerTest method testEdgesOnlyNgramAnalyzer.

@Test
void testEdgesOnlyNgramAnalyzer() throws Exception {
    String input = "hello RL";
    Collection<String> result = new HashSet<>();
    tokenizeWithAnalyzer(result, input, new NgramAnalyzer(null, 3, 10, true));
    Assertions.assertEquals(ImmutableSet.of("hel", "hell", "hello", "rl"), result);
}
Also used : NgramAnalyzer(com.apple.foundationdb.record.lucene.ngram.NgramAnalyzer) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 3 with NgramAnalyzer

use of com.apple.foundationdb.record.lucene.ngram.NgramAnalyzer in project fdb-record-layer by FoundationDB.

the class LuceneAnalyzerTest method testNgramAnalyzer.

@Test
void testNgramAnalyzer() throws Exception {
    String input = "hello RL";
    Collection<String> result = new HashSet<>();
    tokenizeWithAnalyzer(result, input, new NgramAnalyzer(null, 3, 10, false));
    Assertions.assertEquals(ImmutableSet.of("hel", "ell", "llo", "hell", "ello", "hello", "rl"), result);
}
Also used : NgramAnalyzer(com.apple.foundationdb.record.lucene.ngram.NgramAnalyzer) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

NgramAnalyzer (com.apple.foundationdb.record.lucene.ngram.NgramAnalyzer)3 HashSet (java.util.HashSet)3 Test (org.junit.jupiter.api.Test)3 CharArraySet (org.apache.lucene.analysis.CharArraySet)1