本文整理汇总了Java中org.apache.lucene.analysis.core.StopFilterFactory类的典型用法代码示例。如果您正苦于以下问题:Java StopFilterFactory类的具体用法?Java StopFilterFactory怎么用?Java StopFilterFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StopFilterFactory类属于org.apache.lucene.analysis.core包,在下文中一共展示了StopFilterFactory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: trainingSetAnalyser
import org.apache.lucene.analysis.core.StopFilterFactory; //导入依赖的package包/类
/**
* Analyzer dedicated to indexing elements into training set and comparing
* them with document to categorise
*
* @return
* @throws ParseException
* @throws NumberFormatException
*/
@ConditionalOnProperty(prefix = "lucene.categoriser.", value = "useTSetBasedCategoriser")
public @Bean Analyzer trainingSetAnalyser(StopFilterFactory stopFilterFactory,
SynonymFilterFactory synonymFilterFactory) throws NumberFormatException, ParseException {
StopFilterFactory stopFilterFactoryForTSet = null;
if (useStopFilter) {
stopFilterFactoryForTSet = stopFilterFactory;
}
SynonymFilterFactory synonymFilterFactoryForTSet = null;
if (useSynonymFilter) {
synonymFilterFactoryForTSet = synonymFilterFactory;
}
return new TaxonomyTrainingSetAnalyser(stopFilterFactoryForTSet, synonymFilterFactoryForTSet,
Integer.valueOf(maxShingleSize));
}
示例2: getSolrStopWordsForField
import org.apache.lucene.analysis.core.StopFilterFactory; //导入依赖的package包/类
/**
* Obtains stop words for a field from the associated
* {@link StopFilterFactory}, if any.
*/
private Collection<CharArraySet> getSolrStopWordsForField(String fieldName) {
// No need to synchronize here, Carrot2 ensures that instances
// of this class are not used by multiple threads at a time.
if (!solrStopWords.containsKey(fieldName)) {
final Analyzer fieldAnalyzer = core.getLatestSchema().getFieldType(fieldName)
.getIndexAnalyzer();
if (fieldAnalyzer instanceof TokenizerChain) {
final TokenFilterFactory[] filterFactories = ((TokenizerChain) fieldAnalyzer)
.getTokenFilterFactories();
for (TokenFilterFactory factory : filterFactories) {
if (factory instanceof StopFilterFactory) {
// StopFilterFactory holds the stop words in a CharArraySet
solrStopWords.put(fieldName,
((StopFilterFactory) factory).getStopWords());
}
if (factory instanceof CommonGramsFilterFactory) {
solrStopWords.put(fieldName,
((CommonGramsFilterFactory) factory)
.getCommonWords());
}
}
}
}
return solrStopWords.get(fieldName);
}
示例3: getSearchMapping
import org.apache.lucene.analysis.core.StopFilterFactory; //导入依赖的package包/类
@Factory
public SearchMapping getSearchMapping() {
SearchMapping mapping = new SearchMapping();
mapping.analyzerDef("autocompleteEdgeAnalyzer", PatternTokenizerFactory.class)
.tokenizerParam("pattern", "(.*)")
.tokenizerParam("group", "1")
.filter(LowerCaseFilterFactory.class)
.filter(StopFilterFactory.class)
.filter(EdgeNGramFilterFactory.class)
.param("minGramSize", "3")
.param("maxGramSize", "50")
.analyzerDef("autocompletePhoneticAnalyzer", StandardTokenizerFactory.class)
.filter(StandardFilterFactory.class)
.filter(StopFilterFactory.class)
.filter(PhoneticFilterFactory.class)
.param("encoder", "DoubleMetaphone")
.filter(SnowballPorterFilterFactory.class)
.param("language", "English")
.analyzerDef("autocompleteNGramAnalyzer", StandardTokenizerFactory.class)
.filter(WordDelimiterFilterFactory.class)
.filter(LowerCaseFilterFactory.class)
.filter(NGramFilterFactory.class)
.param("minGramSize", "3")
.param("maxGramSize", "20")
.analyzerDef("standardAnalyzer", StandardTokenizerFactory.class)
.filter(LowerCaseFilterFactory.class)
.analyzerDef("exactAnalyzer", StandardTokenizerFactory.class)
.analyzerDef("conceptParentPidsAnalyzer", WhitespaceTokenizerFactory.class);
return mapping;
}
示例4: getSolrStopWordsForField
import org.apache.lucene.analysis.core.StopFilterFactory; //导入依赖的package包/类
/**
* Obtains stop words for a field from the associated
* {@link StopFilterFactory}, if any.
*/
private Collection<CharArraySet> getSolrStopWordsForField(String fieldName) {
// No need to synchronize here, Carrot2 ensures that instances
// of this class are not used by multiple threads at a time.
if (!solrStopWords.containsKey(fieldName)) {
final Analyzer fieldAnalyzer = schema.getFieldType(fieldName)
.getAnalyzer();
if (fieldAnalyzer instanceof TokenizerChain) {
final TokenFilterFactory[] filterFactories = ((TokenizerChain) fieldAnalyzer)
.getTokenFilterFactories();
for (TokenFilterFactory factory : filterFactories) {
if (factory instanceof StopFilterFactory) {
// StopFilterFactory holds the stop words in a CharArraySet
solrStopWords.put(fieldName,
((StopFilterFactory) factory).getStopWords());
}
if (factory instanceof CommonGramsFilterFactory) {
solrStopWords.put(fieldName,
((CommonGramsFilterFactory) factory)
.getCommonWords());
}
}
}
}
return solrStopWords.get(fieldName);
}
示例5: TaxonomyTrainingSetAnalyser
import org.apache.lucene.analysis.core.StopFilterFactory; //导入依赖的package包/类
/**
* Creates a new tokenizer
*
*/
public TaxonomyTrainingSetAnalyser(StopFilterFactory stopFilterFactory, SynonymFilterFactory synonymFilterFactory,
Integer maxShingleSize) {
this.stopFilterFactory = stopFilterFactory;
this.synonymFilterFactory = synonymFilterFactory;
this.maxShingleSize = maxShingleSize;
}
示例6: IAViewTextCasPuncAnalyser
import org.apache.lucene.analysis.core.StopFilterFactory; //导入依赖的package包/类
/**
* Creates a new {@link WhitespaceAnalyzer}
*
*/
public IAViewTextCasPuncAnalyser(StopFilterFactory stopFilterFactory, SynonymFilterFactory synonymFilterFactory,
AnalyzerType analyzerType) {
this.stopFilterFactory = stopFilterFactory;
this.synonymFilterFactory = synonymFilterFactory;
this.analyzerType = analyzerType;
}
示例7: getSolrStopWordsForField
import org.apache.lucene.analysis.core.StopFilterFactory; //导入依赖的package包/类
/**
* Obtains stop words for a field from the associated
* {@link StopFilterFactory}, if any.
*/
private Collection<CharArraySet> getSolrStopWordsForField(String fieldName) {
// No need to synchronize here, Carrot2 ensures that instances
// of this class are not used by multiple threads at a time.
if (!solrStopWords.containsKey(fieldName)) {
final Analyzer fieldAnalyzer = core.getLatestSchema().getFieldType(fieldName)
.getAnalyzer();
if (fieldAnalyzer instanceof TokenizerChain) {
final TokenFilterFactory[] filterFactories = ((TokenizerChain) fieldAnalyzer)
.getTokenFilterFactories();
for (TokenFilterFactory factory : filterFactories) {
if (factory instanceof StopFilterFactory) {
// StopFilterFactory holds the stop words in a CharArraySet
solrStopWords.put(fieldName,
((StopFilterFactory) factory).getStopWords());
}
if (factory instanceof CommonGramsFilterFactory) {
solrStopWords.put(fieldName,
((CommonGramsFilterFactory) factory)
.getCommonWords());
}
}
}
}
return solrStopWords.get(fieldName);
}
示例8: getStopwords
import org.apache.lucene.analysis.core.StopFilterFactory; //导入依赖的package包/类
/**
* Simple wrapper around Lucene resource loading to access Solr-provided stop lists.
* @param loader classpath loader
* @param givenLang ISO 2-char language ID used by lucene for lang-specific filters (./lang)
* @return
* @throws IOException
*/
public static Set<Object> getStopwords(ResourceLoader loader, String givenLang) throws IOException {
String lang = givenLang.toLowerCase();
HashMap<String, String> configurationArgs = new HashMap<>();
configurationArgs.put("words", defaultPath(lang));
configurationArgs.put("format", SNOWBALL_SETS.contains(lang) ? "snowball" : "wordset");
configurationArgs.put("luceneMatchVersion", "6.6");
StopFilterFactory filter = new StopFilterFactory(configurationArgs);
filter.inform(loader);
return filter.getStopWords();
}
示例9: fieldHasIndexedStopFilter
import org.apache.lucene.analysis.core.StopFilterFactory; //导入依赖的package包/类
private boolean fieldHasIndexedStopFilter(String field, SolrQueryRequest req) {
FieldType fieldType = req.getSchema().getFieldType(field);
Analyzer analyzer = fieldType.getIndexAnalyzer();//index analyzer
if (analyzer instanceof TokenizerChain) {
TokenizerChain tokenizerChain = (TokenizerChain) analyzer;
TokenFilterFactory[] tokenFilterFactories = tokenizerChain.getTokenFilterFactories();
for (TokenFilterFactory tokenFilterFactory : tokenFilterFactories) {
if (tokenFilterFactory instanceof StopFilterFactory)
return true;
}
}
return false;
}