Пример #1
0
        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;
            }
        }
Пример #2
0
 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);
     }
 }