zoukankan      html  css  js  c++  java
  • lucene下的一个自定义分词

    public class ICTCLASAnalyzer : Analyzer
        {
            //定义要过滤的词
            public static readonly System.String[] CHINESE_ENGLISH_STOP_WORDS = new string[428];
            public string NoisePath = Environment.CurrentDirectory + "\\data\\stopwords.txt";
            public ICTCLASAnalyzer()
            {
                StreamReader reader = new StreamReader(NoisePath, System.Text.Encoding.Default);
                string noise = reader.ReadLine();
                int i = 0;
                while (!string.IsNullOrEmpty(noise))
                {
                    CHINESE_ENGLISH_STOP_WORDS[i] = noise;
                    noise = reader.ReadLine();
                    i++;
                    if (i >= 428)
                        break;
                }
            }

            public override TokenStream TokenStream(System.String fieldName, System.IO.TextReader reader)
            {
                TokenStream result = new ICTCLASTokenizer(reader);
                result = new StandardFilter(result);
                result = new LowerCaseFilter(result);
              
                result = new StopFilter(result, CHINESE_ENGLISH_STOP_WORDS);
                return result;
            }


        }

  • 相关阅读:
    QTP自动化测试进阶
    疯狂Java实战演义
    软件开发之韵:和谐敏捷
    Android应用开发详解
    操作系统直接决定了计算机系统的整体性能
    iBATIS框架源码剖析
    PHP 5完全攻略
    天气地图系统
    OpenSolaris系统管理
    Asp.net MVC 3实例学习之ExtShop(三)——完成首页
  • 原文地址:https://www.cnblogs.com/wycg1984/p/1722402.html
Copyright © 2011-2022 走看看