Java 类org.apache.lucene.analysis.synonym.SynonymFilterFactory 实例源码

项目:IK-Analyzer-2012FF    文件:IKSynonymAnalyzer.java   
@Override
protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
    Tokenizer token = new IKTokenizer(reader, useSmart);
    Map<String, String> paramsMap = new HashMap<String, String>();
    Configuration cfg = DefaultConfig.getInstance();
    paramsMap.put("luceneMatchVersion", luceneMatchVersion.toString());
    paramsMap.put("synonyms", cfg.getExtSynonymDictionarys().get(0));
    paramsMap.put("ignoreCase", "true");
    SynonymFilterFactory factory = new SynonymFilterFactory(paramsMap);
    ResourceLoader loader = new ClasspathResourceLoader();
    try {
        factory.inform(loader);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return new TokenStreamComponents(token, factory.create(token));
}
项目:taxonomy    文件:TrainingSetConfiguration.java   
/**
    * 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));
   }
项目:NYBC    文件:TestMultiWordSynonyms.java   
public void testMultiWordSynonyms() throws IOException {
  SynonymFilterFactory factory = new SynonymFilterFactory();
  Map<String,String> args = new HashMap<String,String>();
  args.put("synonyms", "synonyms.txt");
  factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
  factory.init(args);
  factory.inform(new StringMockResourceLoader("a b c,d"));
  TokenStream ts = factory.create(new MockTokenizer(new StringReader("a e"), MockTokenizer.WHITESPACE, false));
  // This fails because ["e","e"] is the value of the token stream
  assertTokenStreamContents(ts, new String[] { "a", "e" });
}
项目:taxonomy    文件:IAViewTextGenAnalyser.java   
/**
    * Creates a new tokenizer
    *
    */
   public IAViewTextGenAnalyser(SynonymFilterFactory synonymFilterFactory,
                                WordDelimiterFilterFactory wordDelimiterFilterFactory, AnalyzerType analyzerType) {
       this.synonymFilterFactory = synonymFilterFactory;
this.wordDelimiterFilterFactory = wordDelimiterFilterFactory;
this.analyzerType = analyzerType;
   }
项目:taxonomy    文件:TaxonomyTrainingSetAnalyser.java   
/**
    * Creates a new tokenizer
    * 
    */
   public TaxonomyTrainingSetAnalyser(StopFilterFactory stopFilterFactory, SynonymFilterFactory synonymFilterFactory,
    Integer maxShingleSize) {
this.stopFilterFactory = stopFilterFactory;
this.synonymFilterFactory = synonymFilterFactory;
this.maxShingleSize = maxShingleSize;
   }
项目:taxonomy    文件:IAViewTextCasPuncAnalyser.java   
/**
    * Creates a new {@link WhitespaceAnalyzer}
    * 
    */
   public IAViewTextCasPuncAnalyser(StopFilterFactory stopFilterFactory, SynonymFilterFactory synonymFilterFactory,
    AnalyzerType analyzerType) {
this.stopFilterFactory = stopFilterFactory;
this.synonymFilterFactory = synonymFilterFactory;
this.analyzerType = analyzerType;
   }
项目:taxonomy    文件:IAViewTextCasNoPuncAnalyser.java   
/**
    * Creates a new tokenizer
    *
    */
   public IAViewTextCasNoPuncAnalyser(SynonymFilterFactory synonymFilterFactory,
                                      WordDelimiterFilterFactory wordDelimiterFilterFactory, AnalyzerType analyzerType) {
       this.synonymFilterFactory = synonymFilterFactory;
this.wordDelimiterFilterFactory = wordDelimiterFilterFactory;
this.analyzerType = analyzerType;
   }
项目:taxonomy    文件:IAViewTextNoCasNoPuncAnalyser.java   
/**
    * Creates a new tokenizer
    *
    */
   public IAViewTextNoCasNoPuncAnalyser(SynonymFilterFactory synonymFilterFactory,
                                        WordDelimiterFilterFactory wordDelimiterFilterFactory, AnalyzerType analyzerType) {
       this.synonymFilterFactory = synonymFilterFactory;
this.wordDelimiterFilterFactory = wordDelimiterFilterFactory;
this.analyzerType = analyzerType;
   }