//正向大匹配分詞算法 ,耗時長,這并不是一個很好的算法,我的這個輸出是逆向輸入的 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<String> Reslut = new List<string>(); 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是因為要重新查找, 而要先執(zhí)行循環(huán)中的i++ } } // 當前循環(huán)完畢,詞的末尾截去一個字,繼續(xù)循環(huán), 直到詞變?yōu)榭? 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)
創(chuàng)新互聯(lián)建站專業(yè)為企業(yè)提供澤庫網(wǎng)站建設、澤庫做網(wǎng)站、澤庫網(wǎng)站設計、澤庫網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、澤庫企業(yè)網(wǎng)站模板建站服務,10年澤庫做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。{
String s=inputtext.Text.Trim();
SplitChineseCharacter scc = new SplitChineseCharacter(s);
scc.start();
foreach (String ss in scc.Reslut)
{
output.Text += ss+"/";
}
}
}
}
另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
網(wǎng)站欄目:中文分詞技術-創(chuàng)新互聯(lián)
路徑分享:http://muchs.cn/article36/dsphsg.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供用戶體驗、云服務器、網(wǎng)站內(nèi)鏈、微信小程序、微信公眾號、企業(yè)網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容