日期:2014-05-20  浏览次数:20746 次

.NET2.0泛型就是爽!写了一个分词算法,抖一抖代码.感谢chenzq!
winform中拖一个按钮,两个RichText
using   System;
using   System.Collections.Generic;
using   System.ComponentModel;
using   System.Data;
using   System.Drawing;
using   System.Text;
using   System.Windows.Forms;
 
namespace   cutWord
{
        public   partial   class   Form1   :   Form
        {
                public   Form1()
                {
                        InitializeComponent();
                }

                private   void   button1_Click(object   sender,   EventArgs   e)
                {
                        List <KeyValuePair <string,   int> >   L   =   cutWord(this.richTextBox1.Text);
                        this.richTextBox2.Text   =   " ";
                        int   count   =   0;
                        for   (int   i   =   L.Count-1;   i   > 0;   i--)
                        {
                                if   (count   >   15)
                                {
                                        break;
                                }
                                count++;
                                this.richTextBox2.Text   +=   L[i].Key   + "[ "   +   L[i].Value   + "]\n ";
                        }                                  
                }
                private   List <KeyValuePair <string,   int> >     cutWord(string   article)
                {
                        Dictionary <string,   int>   D   =   new   Dictionary <string,   int> ();
                        //if   len(escape(x))   /len(x)=6   then   isGB=true   else   isGB=false
                        //HttpUtility..::