当前位置: 首页>>代码示例>>Java>>正文


Java StopFilterFactory类代码示例

本文整理汇总了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));
   }
 
开发者ID:nationalarchives,项目名称:taxonomy,代码行数:24,代码来源:TrainingSetConfiguration.java

示例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);
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:SolrStopwordsCarrot2LexicalDataFactory.java

示例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;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:33,代码来源:LuceneSearchMappingFactory.java

示例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);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:31,代码来源:SolrStopwordsCarrot2LexicalDataFactory.java

示例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;
   }
 
开发者ID:nationalarchives,项目名称:taxonomy,代码行数:11,代码来源:TaxonomyTrainingSetAnalyser.java

示例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;
   }
 
开发者ID:nationalarchives,项目名称:taxonomy,代码行数:11,代码来源:IAViewTextCasPuncAnalyser.java

示例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);
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:31,代码来源:SolrStopwordsCarrot2LexicalDataFactory.java

示例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();
}
 
开发者ID:OpenSextant,项目名称:Xponents,代码行数:19,代码来源:LuceneStopwords.java

示例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;
}
 
开发者ID:OpenSextant,项目名称:SolrTextTagger,代码行数:14,代码来源:TaggerRequestHandler.java


注:本文中的org.apache.lucene.analysis.core.StopFilterFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。