【问题标题】:What's the difference between Lucene StandardAnalyzer and EnglishAnalyzer?Lucene StandardAnalyzer 和 EnglishAnalyzer 有什么区别?
【发布时间】:2013-06-09 16:45:57
【问题描述】:

我正在使用 Lucene 4.3 对英文推文进行索引,但是我不确定要使用哪个 Analyzer。 Lucene StandardAnalyzer 和 EnglishAnalyzer 有什么区别?

我还尝试使用以下文本测试 StandardAnalyzer:“XY&Z Corporation - xyz@example.com”。输出是:[xy] [z] [corporation] [xyz] [example.com],但我认为输出将是:[XY&Z] [Corporation] [xyz@example.com]

我做错了吗?

【问题讨论】:

    标签: lucene


    【解决方案1】:

    查看源代码。通常,分析器非常易读。您只需要查看 CreateComponents 方法即可查看它使用的 Tokenizer 和 Filters:

    @Override
    protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
        final Tokenizer source = new StandardTokenizer(matchVersion, reader);
        TokenStream result = new StandardFilter(matchVersion, source);
        // prior to this we get the classic behavior, standardfilter does it for us.
        if (matchVersion.onOrAfter(Version.LUCENE_31))
          result = new EnglishPossessiveFilter(matchVersion, result);
        result = new LowerCaseFilter(matchVersion, result);
        result = new StopFilter(matchVersion, result, stopwords);
        if(!stemExclusionSet.isEmpty())
          result = new KeywordMarkerFilter(result, stemExclusionSet);
        result = new PorterStemFilter(result);
        return new TokenStreamComponents(source, result);
     }
    

    StandardAnalyzer 只是StandardTokenizerStandardFilterLowercaseFilterStopFilterEnglishAnalyzerEnglishPossesiveFilterKeywordMarkerFilterPorterStemFilter 中滚动。

    主要是,EnglishAnalyzer 加入了一些英语词干增强功能,这对于纯英文文本应该很有效。

    对于 StandardAnalyzer,我知道的唯一一个与英语分析直接相关的假设是默认停用词集,当然,这只是一个默认值,可以更改。 StandardAnalyzer 现在实现了Unicode Standard Annex #29,它尝试提供非特定语言的文本分割。

    【讨论】:

      猜你喜欢
      • 2015-03-03
      • 1970-01-01
      • 2017-04-03
      • 2011-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多