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


    }

相关文章:

  • 2021-10-11
  • 2022-12-23
  • 2021-09-22
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-07
相关资源
相似解决方案