`

lucene3.6.0的分析器

 
阅读更多

语汇单元:位置增量是唯一的元数据

poter词干提取算法实现

/**
 *
 * Stemmer, implementing the Porter Stemming Algorithm
 *
 * The Stemmer class transforms a word into its root form.  The input
 * word can be provided a character at time (by calling add()), or at once
 * by calling one of the various stem(something) methods.
 */
PorterStemmer.java


lucene3.6.0 token获取
            TokenStream tokenStream = analyzer.tokenStream("context", new StringReader("旧水泥袋"));
            OffsetAttribute offsetAttribute = tokenStream.addAttribute(OffsetAttribute.class);
            CharTermAttribute charTermAttribute = tokenStream.addAttribute(CharTermAttribute.class);

            while (tokenStream.incrementToken()) {
                int startOffset = offsetAttribute.startOffset();
                int endOffset = offsetAttribute.endOffset();
                String term = charTermAttribute.toString();
                System.out.println(offsetAttribute.toString());
            }

WhiteSpaceAnalyzer  在空格处分隔词汇单元
SimpleAnalyzer   在非字母处切分文本,并进行小写规格化
StopAnalyzer  在非字母处切分文本,并进行小写规格化,再移除停用词
StarderAnalyzer   基于复杂的语法来进行词汇切分,可以识别email,首字母缩写词,汉语-日语-汉语字符,字符数字;小写化;移除停用词


stopAnalyzer停用词表 可以通过构造函数自己设置停用词表
public final class StopAnalyzer extends StopwordAnalyzerBase {
  
  /** An unmodifiable set containing some common English words that are not usually useful
  for searching.*/
  public static final Set<?> ENGLISH_STOP_WORDS_SET;
  
  static {
    final List<String> stopWords = Arrays.asList(
      "a", "an", "and", "are", "as", "at", "be", "but", "by",
      "for", "if", "in", "into", "is", "it",
      "no", "not", "of", "on", "or", "such",
      "that", "the", "their", "then", "there", "these",
      "they", "this", "to", "was", "will", "with"
    );
    final CharArraySet stopSet = new CharArraySet(Version.LUCENE_CURRENT, 
        stopWords.size(), false);
    stopSet.addAll(stopWords);  
    ENGLISH_STOP_WORDS_SET = CharArraySet.unmodifiableSet(stopSet); 
  }
  /** Builds an analyzer with the stop words from the given set.
   * @param matchVersion See <a href="#version">above</a>
   * @param stopWords Set of stop words */
  public StopAnalyzer(Version matchVersion, Set<?> stopWords) {
    super(matchVersion, stopWords);
  }

StarderAnalyzer:基于javacc,也可以通过构造函数传递停用词表,来达到stopAnalyzer的功能。

PerFieldAnalyzerWrapper.java能够针对某个域采用不同的分析器。

 *   Map analyzerPerField = new HashMap();
 *   analyzerPerField.put("firstname", new KeywordAnalyzer());
 *   analyzerPerField.put("lastname", new KeywordAnalyzer());
 *
 *   PerFieldAnalyzerWrapper aWrapper =
 *      new PerFieldAnalyzerWrapper(new StandardAnalyzer(), analyzerPerField);
 
分享到:
评论

相关推荐

    lucene-3.6.0

    Lucene 3.6.0包含了多个预定义的分析器,如StandardAnalyzer、SimpleAnalyzer等,同时支持自定义分析器,以适应不同语言和领域的文本处理需求。 4. **存储与检索**:Lucene支持多种存储方式,包括内存存储和磁盘...

    lucene-3.6.0.zip

    4. 多语言支持:3.6.0版本提供了更多的语言分析器,支持不同语言的文本处理,如中文、法文、德文等。 5. 高级搜索功能:引入了对地理位置搜索的支持,通过地理坐标实现附近的搜索。 6. 更新管理:优化了索引更新...

    IK和Lucene

    IK Analyzer是由尹吉团队开发的,它的全称为"Intelligent Chinese Analyzer",意为智能中文分析器。它主要的任务是对中文文本进行分词,这是中文信息处理的基础,因为计算机无法直接理解和处理中文的连续字符流。IK ...

    lucene jar包

    3.6.0可能包含了对分析器的改进,支持更多种语言的文本处理,以及对复杂查询结构的支持。此外,这个版本也可能引入了对倒排索引的进一步优化,提高了搜索速度。这个版本更适合那些需要处理大量数据和复杂查询的项目...

    lucene-core-3.6.0.jar.zip

    Lucene是apache软件基金会4 jakarta项目组的一个子项目,是一个开放源代码的全文检索引擎工具包,但它不是一个完整的全文检索引擎,而是一个全文检索引擎的架构,提供了完整的查询引擎和索引引擎,部分文本分析引擎...

    lucene5.X与lucene3.60的版本差异

    这使得构造建议器和分析器更加灵活,同时提高了测试的针对性。 2. Lucene-4535:`OpenUtil.filterIterator`被标记为内部API,意味着开发者不应直接依赖此API,而是应该使用推荐的公开接口。 3. Lucene-4924:`...

    IKanalyzer2012修复与Lucene3.6.2Jar及IK使用示例

    标题中的“IKanalyzer2012修复与Lucene3.6.2Jar及IK使用示例”指的是一项关于优化IKAnalyzer2012版本的活动,这是一款流行的中文分词器,常用于Java环境下的信息检索和文本分析。Lucene3.6.2Jar则是Apache Lucene的...

    lucene全文检索实例二(实现对10万条数据检索文件的增删改查操作)

    6. `lucene-kuromoji-3.6.0-javadoc.jar`:这个是Lucene的日语分词器Kuromoji的API文档,用于处理日语文本。 7. `gson-2.2.2.jar`:Google的Gson库,用于JSON对象和Java对象之间的转换,可能在数据序列化或网络通信...

    lucene.rar

    2. **lucene-analyzers-3.5.0.jar**:这个库提供了各种分析器,用于将输入的原始文本转换成可以被搜索引擎处理的形式。分析器的作用包括分词、去除停用词、词形还原等,例如英文的StandardAnalyzer,中文的...

    solr-3.6.0-src

    "solr-3.6.0-src" 提供的是 Solr 3.6.0 版本的源代码,允许开发者深入理解 Solr 的工作原理,并对其进行定制和扩展。这个版本在 Solr 的发展史上占有重要地位,它包含了当时最新的特性和改进。 1. **Solr 概述** ...

    luke-6.0.0

    5. **配置检查**:Luke显示了Lucene的配置设置,包括各种索引选项和分析器配置。 6. **性能分析**:通过查看查询执行时间和内存使用情况,可以帮助用户评估和优化索引的性能。 总的来说,Luke 6.0.0是Lucene开发者...

Global site tag (gtag.js) - Google Analytics