private void button2_Click(object sender, EventArgs e) { float p = 0f, r = 0f, f = 0f; try { string dir = Path.GetDirectoryName(Path.GetFullPath(textBox1.Text.Split(';')[0])); string testPath = Path.Combine(dir, "crfTestDoc.txt"); string resultPath = Path.Combine(dir, "crfResultDoc.txt"); string args = string.Format(" -m {0} {1}", textBox2.Text, testPath); //如果是字特征/字+词性特征把这里改成ConvertAnnsToBio1/ConvertAnnsToBio2 CRF.ConvertAnnsToBio3(testPath, textBox1.Text.Split(';')); ProcessUtils.StartProcessRedirect("crf_test.exe", resultPath, args); //如果是字特征/字+词性特征把这里改成Score1/Score2 CRF.Score3(resultPath, ref p, ref r, ref f); lblP.Text = p.ToString(); lblR.Text = r.ToString(); lblF.Text = f.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message); //throw; } }
private void button3_Click(object sender, EventArgs e) { try { string dir = Path.GetDirectoryName(Path.GetFullPath(textBox1.Text)); string testPath = Path.Combine(dir, "crfTestDoc.txt"); string resultPath = Path.Combine(dir, "crfResultDoc.txt"); CRF.WriteSentenceToFile3(Preprocessor.RemoveInvalidString(textBox2.Text), testPath); string args = string.Format(" -m {0} {1}", textBox1.Text, testPath); ProcessUtils.StartProcessRedirect("crf_test.exe", resultPath, args); var list = CRF.GetNameEntityFromFile(resultPath); var dict = CRF.MergeNameEntity(list); //在这里必须创建一个BindIngSource对象,用该对象接收Dictionary<>泛型集合的对象 BindingSource bs = new BindingSource(); //将泛型集合对象的值赋给BindingSourc对象的数据源 bs.DataSource = dict; this.dataGridView1.DataSource = bs; } catch (Exception ex) { MessageBox.Show(ex.Message); //throw; } }
private void button1_Click(object sender, EventArgs e) { try { CRF.TestAll(textBox2.Text); MessageBox.Show("任务已完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "出错啦", MessageBoxButtons.OK, MessageBoxIcon.Error); //throw; } }
private void button4_Click(object sender, EventArgs e) { try { var dir = Path.GetDirectoryName(txtTrainDoc.Text.Split(';')[0]); var bioFile = "data/crfTrainDoc.txt"; CRF.ConvertAnnsToBio3(bioFile, txtTrainDoc.Text.Split(';')); string args = string.Format(@"{0} {1} {2} {3}", txtTemplate.Text, bioFile, txtModel.Text, txtOther.Text); //var aString = Encoding.Default.GetString(Encoding.UTF8.GetBytes(args)); ProcessUtils.StartProcess("crf_learn.exe", args); MessageBox.Show("训练完成"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }