Form1.cs
上传用户:hshongkong
上传日期:2021-11-20
资源大小:10241k
文件大小:2k
- using System;
- using System.Threading;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- using ChineseSplitter;
- namespace TestSpliter
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- string[] strs = null;
- private void button1_Click(object sender, EventArgs e)
- {
- if (textBox1.Text.Trim().Length < 2)
- {
- MessageBox.Show("输入字符不能少于两个");
- textBox1.Focus();
- return;
- }
- DefaultSplitter tool = new DefaultSplitter(new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"CacheFolder"));
- string result = tool.Split(textBox1.Text);
- KeywordsSort mySort = new KeywordsSort();
- mySort.Append(result);
- this.label1.Text = result;
- strs = mySort.GetTopKeywords(100).Split(' ');
- for (int i = 0; i < strs.Length; i++)
- {
- this.label1.Text += strs[i] + "n";
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- string[] roles1 = richTextBox2.Text.Split(',');
- string[] roles2 = richTextBox3.Text.Split(',');
- string[] str = strs;
- int c1 = 0;
- int c2 = 0;
- c1 = ChineseSplitter.ClaassPercent.Getpercent(roles1, str);
- c2 = ChineseSplitter.ClaassPercent.Getpercent(roles2, str);
- if (c1 > c2)
- {
- richTextBox1.Text = "分类一,积分:" + c1.ToString();
- }
- else
- {
- richTextBox1.Text = "分类二,积分:" + c2.ToString();
- }
- }
- }
- }