示例#1
0
        public string[] get_word(string index)
        {
            string[] s =new string[100];
            StringBuilder sb = new StringBuilder();
            sb.Remove(0, sb.Length);
            string t1 = "";
            int i = 0;
            Analyzer analyzer = new Lucene.China.ChineseAnalyzer();
            StringReader sr = new StringReader(index);
            TokenStream stream = analyzer.TokenStream(null, sr);

            long begin = System.DateTime.Now.Ticks;
            Token t = stream.Next();
            while (t != null)
            {
                t1 = t.ToString();   //显示格式: (关键词,0,2) ,需要处理
                t1 = t1.Replace("(", "");
                char[] separator = { ',' };
                t1 = t1.Split(separator)[0];
                s[i] = t1;
                t = stream.Next();
                i++;
            }
            return s;
        }
示例#2
0
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            sb.Remove(0, sb.Length);
            string t1 = "";
            int i = 0;
            Analyzer analyzer = new Lucene.China.ChineseAnalyzer();
            StringReader sr = new StringReader("今天天气真的很好!");
            TokenStream stream = analyzer.TokenStream(null, sr);

            long begin = System.DateTime.Now.Ticks;
            Token t = stream.Next();
            while (t != null)
            {
                t1 = t.ToString();   //显示格式: (关键词,0,2) ,需要处理
                t1 = t1.Replace("(", "");
                char[] separator = { ',' };
                t1 = t1.Split(separator)[0];

                sb.Append(i + ":" + t1 + "\r\n");
                Console.WriteLine(t1);
                t = stream.Next();
                i++;
            }
            txtSearched.Text += "ok";
            txtSearched.Text += sb.ToString();
        }
示例#3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            sb.Remove(0, sb.Length);
            string       t1       = "";
            int          i        = 0;
            Analyzer     analyzer = new Lucene.China.ChineseAnalyzer();
            StringReader sr       = new StringReader(TextBox1.Text);
            TokenStream  stream   = analyzer.TokenStream(null, sr);

            long  begin = System.DateTime.Now.Ticks;
            Token t     = stream.Next();

            while (t != null)
            {
                t1 = t.ToString();   //显示格式: (关键词,0,2) ,需要处理
                t1 = t1.Replace("(", "");
                char[] separator = { ',' };
                t1 = t1.Split(separator)[0];

                sb.Append(i + ":" + t1 + "\r\n");
                t = stream.Next();
                i++;
            }
            TextBox2.Text = sb.ToString();
            long end  = System.DateTime.Now.Ticks;    //100毫微秒
            int  time = (int)((end - begin) / 10000); //ms


            TextBox2.Text += "耗时" + (time) + "ms \r\n=================================\r\n";
        }
示例#4
0
        //关键词查询
        private void RetriveTokenFromQuery(string queryText)
        {
            string       curNewToken = "";
            Analyzer     analyzer    = new Lucene.China.ChineseAnalyzer();
            StringReader sr          = new StringReader(queryText);
            TokenStream  stream      = analyzer.TokenStream(null, sr);
            Token        nextToken   = stream.Next();

            while (nextToken != null)
            {
                curNewToken = nextToken.ToString();   //显示格式: (关键词,0,2) ,需要处理
                curNewToken = curNewToken.Replace("(", "");
                char[] separator = { ',' };
                curNewToken = curNewToken.Split(separator)[0];
                //StoreTokenIntoList(curNewToken, fileIndex);
                this.queryTerms.Add(curNewToken);
                nextToken = stream.Next();
            }
        }
        //关键词查询
        private void RetriveTokenFromQuery(string queryText)
        {
            string curNewToken = "";
            Analyzer analyzer = new Lucene.China.ChineseAnalyzer();
            StringReader sr = new StringReader(queryText);
            TokenStream stream = analyzer.TokenStream(null, sr);
            Token nextToken = stream.Next();

            while (nextToken != null)
            {
                curNewToken = nextToken.ToString();   //显示格式: (关键词,0,2) ,需要处理
                curNewToken = curNewToken.Replace("(", "");
                char[] separator = { ',' };
                curNewToken = curNewToken.Split(separator)[0];
                //StoreTokenIntoList(curNewToken, fileIndex);
                this.queryTerms.Add(curNewToken);
                nextToken = stream.Next();
            }
        }