www.pudn.com > classifier.rar > splitTest.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Threading;
namespace classifier
{
///
/// splitTest 的摘要说明。
///
public class splitTest : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox inputBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox resultBox;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button splitBtn;
private System.Windows.Forms.Timer timer1;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.TextBox outputBox1;
private System.Windows.Forms.TextBox outputBox2;
private split.stringSpliter sp;
private Thread sThread;
public splitTest()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.inputBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.outputBox1 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.outputBox2 = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.resultBox = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.splitBtn = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// inputBox
//
this.inputBox.Location = new System.Drawing.Point(120, 24);
this.inputBox.Multiline = true;
this.inputBox.Name = "inputBox";
this.inputBox.Size = new System.Drawing.Size(496, 80);
this.inputBox.TabIndex = 0;
this.inputBox.Text = "";
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 23);
this.label1.TabIndex = 1;
this.label1.Text = "输入文本段:";
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(96, 23);
this.label2.TabIndex = 2;
this.label2.Text = "正向扫描结果:";
//
// outputBox1
//
this.outputBox1.Location = new System.Drawing.Point(120, 24);
this.outputBox1.Multiline = true;
this.outputBox1.Name = "outputBox1";
this.outputBox1.Size = new System.Drawing.Size(496, 80);
this.outputBox1.TabIndex = 3;
this.outputBox1.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(8, 120);
this.label3.Name = "label3";
this.label3.TabIndex = 4;
this.label3.Text = "逆向扫描结果:";
//
// outputBox2
//
this.outputBox2.Location = new System.Drawing.Point(120, 120);
this.outputBox2.Multiline = true;
this.outputBox2.Name = "outputBox2";
this.outputBox2.Size = new System.Drawing.Size(496, 72);
this.outputBox2.TabIndex = 5;
this.outputBox2.Text = "";
//
// label4
//
this.label4.Location = new System.Drawing.Point(8, 208);
this.label4.Name = "label4";
this.label4.TabIndex = 6;
this.label4.Text = "最终结果:";
//
// resultBox
//
this.resultBox.Location = new System.Drawing.Point(120, 208);
this.resultBox.Multiline = true;
this.resultBox.Name = "resultBox";
this.resultBox.Size = new System.Drawing.Size(496, 72);
this.resultBox.TabIndex = 7;
this.resultBox.Text = "";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.outputBox1);
this.groupBox1.Controls.Add(this.outputBox2);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.resultBox);
this.groupBox1.Location = new System.Drawing.Point(8, 176);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(632, 296);
this.groupBox1.TabIndex = 8;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "扫描结果";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.splitBtn);
this.groupBox2.Controls.Add(this.inputBox);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Location = new System.Drawing.Point(8, 16);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(632, 152);
this.groupBox2.TabIndex = 9;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "扫描输入";
//
// splitBtn
//
this.splitBtn.Location = new System.Drawing.Point(288, 120);
this.splitBtn.Name = "splitBtn";
this.splitBtn.TabIndex = 2;
this.splitBtn.Text = "分词";
this.splitBtn.Click += new System.EventHandler(this.splitBtn_Click);
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// splitTest
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(648, 485);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "splitTest";
this.Text = "分词测试";
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void splitBtn_Click(object sender, System.EventArgs e)
{
if(inputBox.Text.Trim()!="")
{
sp=new classifier.split.stringSpliter(inputBox.Text.Trim());
sThread=new Thread(new ThreadStart(sp.readToEnd));
timer1.Interval=5000;
sThread.Start();
// //sThread启动前的延迟
// while(!sThread.IsAlive);
//当前线程停止1ms等待sThread作写工作
//等待线程结束
sThread.Join();
outputBox1.Text="";
for(int i=0;i=0;i--)
{
outputBox2.Text+=sp.rightRes[i].ToString()+" ";
}
//最终结果
resultBox.Text="";
for(int i=0;i