189 8069 5689

中文分词技术-创新互联

//正向大匹配分词算法 ,耗时长,这并不是一个很好的算法,我的这个输出是逆向输入的
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClusterCharater
{
    public class SplitChineseCharacter
    {

        private String[] dictionary = { "今天", "是","星期" ,"六","星期六" }; //词典
        private String input = null;
        public List Reslut = new List();

        public SplitChineseCharacter(String input)
        {
            this.input = input;
        }

        public void start()
        {
            String temp = null;
            for (int i = 0; i < this.input.Length; i++)
            {
                temp = this.input.Substring(i); // 每次从字符串的首部截取一个字,并存到temp中
                // 如果该词在字典中, 则删除该词并在原始字符串中截取该词
                if (this.isInDictionary(temp))
                {
                    Reslut.Add(temp);
                    this.input = this.input.Replace(temp, "");
                    i = -1; // i=-1是因为要重新查找, 而要先执行循环中的i++
                }
            }

            // 当前循环完毕,词的末尾截去一个字,继续循环, 直到词变为空
            if (null != this.input && !"".Equals(this.input))
            {
                this.input = this.input.Substring(0, this.input.Length - 1);
                this.start();
            }
        }

        //判断当前词是否在字典中
        public Boolean isInDictionary(String temp)
        {
            for (int i = 0; i < this.dictionary.Length; i++)
            {
                if (temp.Equals(this.dictionary[i]))
                {
                    return true;
                }
            }
            return false;
        }
    }
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ClusterCharater
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

    private void button1_Click(object sender, EventArgs e)

创新互联建站专业为企业提供泽库网站建设、泽库做网站、泽库网站设计、泽库网站制作等企业网站建设、网页设计与制作、泽库企业网站模板建站服务,10年泽库做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

    {

      String s=inputtext.Text.Trim();

      SplitChineseCharacter scc = new SplitChineseCharacter(s);

      scc.start();

      foreach (String ss in scc.Reslut)

      {

        output.Text += ss+"/";

      }

    }

  }

}

中文分词技术

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享名称:中文分词技术-创新互联
URL分享:http://cdxtjz.cn/article/dsphsg.html

其他资讯