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;
            }


        }

  • 相关阅读:
    JUnit4.13环境配置
    OO第5-7次作业总结
    电梯的一点浅优化
    C++变量作用域、生存期、存储类别
    最后一次OO博客
    OO第三次总结
    OO第二次总结
    OO第一次总结
    POJ3934
    POJ刷题计划
  • 原文地址:https://www.cnblogs.com/wycg1984/p/1722402.html
Copyright © 2011-2022 走看看