本文整理汇总了Java中org.apache.lucene.analysis.core.StopFilter.makeStopSet方法的典型用法代码示例。如果您正苦于以下问题:Java StopFilter.makeStopSet方法的具体用法?Java StopFilter.makeStopSet怎么用?Java StopFilter.makeStopSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.analysis.core.StopFilter
的用法示例。
在下文中一共展示了StopFilter.makeStopSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEndingHole
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testEndingHole() throws Exception {
// Just deletes "of"
Analyzer a = new Analyzer() {
@Override
public TokenStreamComponents createComponents(String field, Reader reader) {
Tokenizer tokenizer = new MockTokenizer(reader);
CharArraySet stopSet = StopFilter.makeStopSet("of");
return new TokenStreamComponents(tokenizer, new StopFilter(tokenizer, stopSet));
}
};
Iterable<Input> keys = AnalyzingSuggesterTest.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:
assertEquals("oz/0.20",
toString(sug.lookup("wizard o", 10)));
}
示例2: testTwoEndingHoles
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testTwoEndingHoles() throws Exception {
// Just deletes "of"
Analyzer a = new Analyzer() {
@Override
public TokenStreamComponents createComponents(String field, Reader reader) {
Tokenizer tokenizer = new MockTokenizer(reader);
CharArraySet stopSet = StopFilter.makeStopSet("of");
return new TokenStreamComponents(tokenizer, new StopFilter(tokenizer, stopSet));
}
};
Iterable<Input> keys = AnalyzingSuggesterTest.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)));
}
示例3: testEndIsStopWord
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testEndIsStopWord() throws Exception {
CharArraySet stopWords = StopFilter.makeStopSet("to");
TokenStream stream = new MockTokenizer(new StringReader("go to "));
TokenStream filter = new SuggestStopFilter(stream, stopWords);
filter = new SuggestStopFilter(stream, stopWords);
assertTokenStreamContents(filter,
new String[] {"go"},
new int[] {0},
new int[] {2},
null,
new int[] {1},
null,
6,
new boolean[] {false},
true);
}
示例4: testMidStopWord
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMidStopWord() throws Exception {
CharArraySet stopWords = StopFilter.makeStopSet("to");
TokenStream stream = new MockTokenizer(new StringReader("go to school"));
TokenStream filter = new SuggestStopFilter(stream, stopWords);
filter = new SuggestStopFilter(stream, stopWords);
assertTokenStreamContents(filter,
new String[] {"go", "school"},
new int[] {0, 6},
new int[] {2, 12},
null,
new int[] {1, 2},
null,
12,
new boolean[] {false, false},
true);
}
示例5: testMultipleStopWords
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMultipleStopWords() throws Exception {
CharArraySet stopWords = StopFilter.makeStopSet("to", "the", "a");
TokenStream stream = new MockTokenizer(new StringReader("go to a the school"));
TokenStream filter = new SuggestStopFilter(stream, stopWords);
filter = new SuggestStopFilter(stream, stopWords);
assertTokenStreamContents(filter,
new String[] { "go", "school" },
new int[] {0, 12},
new int[] {2, 18},
null,
new int[] {1, 4},
null,
18,
new boolean[] {false, false},
true);
}
示例6: testMultipleStopWordsEnd
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMultipleStopWordsEnd() throws Exception {
CharArraySet stopWords = StopFilter.makeStopSet("to", "the", "a");
TokenStream stream = new MockTokenizer(new StringReader("go to a the"));
TokenStream filter = new SuggestStopFilter(stream, stopWords);
filter = new SuggestStopFilter(stream, stopWords);
assertTokenStreamContents(filter,
new String[] { "go", "the"},
new int[] {0, 8},
new int[] {2, 11},
null,
new int[] {1, 3},
null,
11,
new boolean[] {false, true},
true);
}
示例7: testMultipleStopWordsEnd2
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMultipleStopWordsEnd2() throws Exception {
CharArraySet stopWords = StopFilter.makeStopSet("to", "the", "a");
TokenStream stream = new MockTokenizer(new StringReader("go to a the "));
TokenStream filter = new SuggestStopFilter(stream, stopWords);
filter = new SuggestStopFilter(stream, stopWords);
assertTokenStreamContents(filter,
new String[] { "go"},
new int[] {0},
new int[] {2},
null,
new int[] {1},
null,
12,
new boolean[] {false},
true);
}
示例8: testEndingHole
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testEndingHole() throws Exception {
// Just deletes "of"
Analyzer a = new Analyzer() {
@Override
public TokenStreamComponents createComponents(String field, Reader reader) {
Tokenizer tokenizer = new MockTokenizer(reader);
CharArraySet stopSet = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "of");
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)));
// Falls back to unigram model, with backoff 0.4 times
// prop 0.5:
assertEquals("oz/0.20",
toString(sug.lookup("wizard o", 10)));
}
示例9: testTwoEndingHoles
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testTwoEndingHoles() throws Exception {
// Just deletes "of"
Analyzer a = new Analyzer() {
@Override
public TokenStreamComponents createComponents(String field, Reader reader) {
Tokenizer tokenizer = new MockTokenizer(reader);
CharArraySet stopSet = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "of");
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)));
}
示例10: testEndIsStopWord
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testEndIsStopWord() throws Exception {
CharArraySet stopWords = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "to");
TokenStream stream = new MockTokenizer(new StringReader("go to "));
TokenStream filter = new SuggestStopFilter(stream, stopWords);
filter = new SuggestStopFilter(stream, stopWords);
assertTokenStreamContents(filter,
new String[] {"go"},
new int[] {0},
new int[] {2},
null,
new int[] {1},
null,
6,
new boolean[] {false},
true);
}
示例11: testMidStopWord
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMidStopWord() throws Exception {
CharArraySet stopWords = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "to");
TokenStream stream = new MockTokenizer(new StringReader("go to school"));
TokenStream filter = new SuggestStopFilter(stream, stopWords);
filter = new SuggestStopFilter(stream, stopWords);
assertTokenStreamContents(filter,
new String[] {"go", "school"},
new int[] {0, 6},
new int[] {2, 12},
null,
new int[] {1, 2},
null,
12,
new boolean[] {false, false},
true);
}
示例12: testMultipleStopWords
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMultipleStopWords() throws Exception {
CharArraySet stopWords = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "to", "the", "a");
TokenStream stream = new MockTokenizer(new StringReader("go to a the school"));
TokenStream filter = new SuggestStopFilter(stream, stopWords);
filter = new SuggestStopFilter(stream, stopWords);
assertTokenStreamContents(filter,
new String[] { "go", "school" },
new int[] {0, 12},
new int[] {2, 18},
null,
new int[] {1, 4},
null,
18,
new boolean[] {false, false},
true);
}
示例13: testMultipleStopWordsEnd
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMultipleStopWordsEnd() throws Exception {
CharArraySet stopWords = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "to", "the", "a");
TokenStream stream = new MockTokenizer(new StringReader("go to a the"));
TokenStream filter = new SuggestStopFilter(stream, stopWords);
filter = new SuggestStopFilter(stream, stopWords);
assertTokenStreamContents(filter,
new String[] { "go", "the"},
new int[] {0, 8},
new int[] {2, 11},
null,
new int[] {1, 3},
null,
11,
new boolean[] {false, true},
true);
}
示例14: testMultipleStopWordsEnd2
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
public void testMultipleStopWordsEnd2() throws Exception {
CharArraySet stopWords = StopFilter.makeStopSet(TEST_VERSION_CURRENT, "to", "the", "a");
TokenStream stream = new MockTokenizer(new StringReader("go to a the "));
TokenStream filter = new SuggestStopFilter(stream, stopWords);
filter = new SuggestStopFilter(stream, stopWords);
assertTokenStreamContents(filter,
new String[] { "go"},
new int[] {0},
new int[] {2},
null,
new int[] {1},
null,
12,
new boolean[] {false},
true);
}
示例15: LuceneAnalyzerUtil
import org.apache.lucene.analysis.core.StopFilter; //导入方法依赖的package包/类
/**
* Creates an analyzer instance based on user provided stop words. If @param addToDefault is set to true, then
* user provided stop words will be added to the Lucene default stopset.
*/
public LuceneAnalyzerUtil(StemFilterType stemFilterType, List<String> stopWords, boolean addToDefault) {
LuceneAnalyzerUtil.stemFilterType = stemFilterType;
if(addToDefault) {
stopSet.addAll(stopWords);
}
else {
stopSet = StopFilter.makeStopSet(stopWords);
}
}