private void StandardizationButton_Click(object sender, EventArgs e) { ClossButton(); MyData.TheDoc = MyFun.DocStandardization(MyData.TheDoc); StatusLabel.Text = "Document standardization process has been completed."; OpenButton(); }
private void RemoveStopButton_Click(object sender, EventArgs e) { ClossButton(); MessageBox.Show("Tip: If the document is longer, it may take you few minutes, please be patient ...", "Prompt", 0, MessageBoxIcon.Asterisk); MyData.TheDoc = MyFun.RemoveStop(MyData.TheDoc); StatusLabel.Text = "Remove stop-words has been completed."; OpenButton(); }
private void DoWork() { lock (this) { ClossButton(); DateTime dt1 = DateTime.Now; StatusLabel.Text = "Keyword extraction process is ongoing:0%"; ResultListView.Items.Clear(); MyData.WordsFre = MyFun.StatisticsWords(MyData.TheDoc); for (int i = 0; i < MyData.WordsFre.Length; i++) { MyData.WordsFre[i].EntropyDifference_Max(); progressBar1.Value = i * 100 / MyData.WordsFre.Length; StatusLabel.Text = "Keyword extraction process is ongoing: " + progressBar1.Value + "%"; } MyFun.QuickSort(MyData.WordsFre, 0, MyData.WordsFre.Length - 1); int WordsNum = 0; for (int i = 0; i < MyData.WordsFre.Length; i++) { if (MyData.WordsFre[i].ED > 0) { WordsNum++; } else { break; } } ListViewItem[] lvi = new ListViewItem[WordsNum]; for (int i = 0; i < WordsNum; i++) { lvi[i] = new ListViewItem(); lvi[i].SubItems[0].Text = (i + 1).ToString(); lvi[i].SubItems.Add(MyData.WordsFre[i].Word.ToString()); lvi[i].SubItems.Add(MyData.WordsFre[i].ED.ToString()); lvi[i].SubItems.Add(MyData.WordsFre[i].Frequency.ToString()); } ResultListView.Items.AddRange(lvi); DateTime dt2 = DateTime.Now; SaveButton.Enabled = true; progressBar1.Value = 100; StatusLabel.Text = "Keyword extraction has been completed. The extraction spend " + (dt2 - dt1).ToString() + "."; OpenButton(); } }
private void ParticipleButton_Click(object sender, EventArgs e) { ClossButton(); MessageBox.Show("提示:如果文档较长,可能需要一些时间,请耐心等待...", "提示", 0, MessageBoxIcon.Asterisk); // 系统初始化 if (!MyFun.ICTCLAS_Init(null)) { System.Console.WriteLine("Init ICTCLAS failed!"); System.Console.Read(); } //导入用户字典 string path = @"userdic.txt"; Encoding encode = Encoding.GetEncoding("GB2312"); string userdic = File.ReadAllText(path, encode); MyFun.ICTCLAS_ImportUserDict(userdic, userdic.Length, eCodeType.CODE_TYPE_UNKNOWN); int count = MyData.TheDoc.Length; //先得到结果的词数 result_t[] result = new result_t[count]; //在客户端申请资源 int i = 0; //对字符串进行分词处理 int nWrdCnt = MyFun.ICTCLAS_ParagraphProcessAW(MyData.TheDoc, result, eCodeType.CODE_TYPE_GB, 1); result_t r; //取字符串真实长度 byte[] mybyte = System.Text.Encoding.Default.GetBytes(MyData.TheDoc); byte[] byteWord; string TheDoc = ""; for (i = 0; i < nWrdCnt; i++) { r = result[i]; byteWord = new byte[r.length]; //取字符串一部分 Array.Copy(mybyte, r.start, byteWord, 0, r.length); string wrd = System.Text.Encoding.Default.GetString(byteWord); if (wrd == " ") { continue; } if (i == 0) { TheDoc += wrd; } else { TheDoc += " " + wrd; } } //释放资源退出 MyFun.ICTCLAS_Exit(); MyData.TheDoc = TheDoc; StatusLabel.Text = "中文分词已经完成。"; OpenButton(); }