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