用户操作
[即时聊天] [发私信] [加为好友]
潘宇光ID:superdullwolf
32461次访问,排名3601好友34人,关注者268
超级大笨狼,每天要自强。
superdullwolf的文章
原创 53 篇
翻译 0 篇
转载 0 篇
评论 65 篇
最近评论
devoc:很厉害哦你
devoc:晕,怎么点三下就发了三了次哦。麻烦lz删两个哈~
devoc:晕,怎么点三下就发了三了次哦。麻烦lz删两个哈~
devoc:晕,怎么点三下就发了三了次哦。麻烦lz删两个哈~
devoc:受教了
文章分类
收藏
    相册
    偶的照片
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 .NET2.0泛型就是爽!写了一个分词算法,抖一抖代码收藏

    新一篇: 面试官告诉你如何写简历,一招就灵!  | 旧一篇: 数据库设计多对多关系的几种形态(7种)。

     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..::

                            System.Text.RegularExpressions.Regex   Re   =   new   System.Text.RegularExpressions.Regex(@ "[^\u4e00-\u9fa5]+ ");
                            for   (int   l   =   2;   l   <=   4;   l++)
                            {
                                    for   (int   i   =   0;   i   <   article.Length-l;   i++)
                                    {
                                            string   theWord   =   article.Substring(i,   l);
                                            if   (Re.Replace(theWord, " ")   ==   theWord)
                                            {
                                                    if   (D.ContainsKey(theWord))
                                                    {
                                                            D[theWord]++;
                                                    }
                                                    else
                                                    {
                                                            D.Add(theWord,1);
                                                    }
                                            }                                                            
                                    }
                            }
                   
                            List <KeyValuePair <string,   int> >   L   =   new   List <KeyValuePair <string,   int> > ();
                            foreach   (KeyValuePair <string,   int>   K   in   D)
                            {
                                    if   (K.Value   >   1)
                                    {
                                            L.Add(K);
                                    }
                                   
                                           
                            }

                            L.Sort(
                                    delegate(KeyValuePair <String,   int>   a,   KeyValuePair <String,   int>   b)
                                    {                                    
                                            if   (a.Value   ==   b.Value)
                                            {
                                                    if   (a.Key.Length   ==   b.Key.Length)
                                                    {
                                                            return   0;
                                                    }
                                                    else
                                                    {
                                                            if   (a.Key.Length   >   b.Key.Length)
                                                            {
                                                                    return   1;
                                                            }
                                                            else
                                                            {
                                                                    return   -1;
                                                            }
                                                    }                                                
                                            }
                                            if   (a.Value   >   b.Value)
                                            {
                                                    return   1;
                                            }
                                            else
                                            {
                                                    return   -1;
                                            }
                                           
                                    }

                            );
                            return   (L);

                    }
            }
    }

    测试Sohu首页关键字和频率:
    女人[20]
    搜狐[16]
    手机[13]
    游戏[13]
    博客[13]
    明星[11]
    留学[10]
    美女[9]
    大学[9]
    上海[9]
    中国[9]
    北京[9]
    奥运[9]
    曝光[9]
    开盘[9]
    视频[8]

    晕!女人排第一
    新浪:

    中国[22]
    视频[20]
    手机[14]
    上海[13]
    新浪[13]
    北京[12]
    北大[12]
    国际[12]
    投资[11]
    清华[11]
    博客[11]
    直播[11]
    大学[10]
    留学[10]
    项目[9]
    赚钱[9]

    再看CSDN首页:
    软件[16]
    程序[13]
    程序员[11]
    序员[11]
    开发[11]
    大会[7]
    微软[7]
    我的[7]
    专区[6]
    技术[6]
    中国[5]
    使用[5]
    我们[5]
    模式[5]
    系统[5]
    人才[5]


    发表于 @ 2008年07月22日 17:14:00|评论(loading...)|收藏

    新一篇: 面试官告诉你如何写简历,一招就灵!  | 旧一篇: 数据库设计多对多关系的几种形态(7种)。

    评论:没有评论。

    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © 潘宇光