以下代码可以编译通过,运行程序时却出现了一个提示框,显示:出现了一个问题,导致程序停止正常工作,请关闭该程序。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PanGu;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
Segment.Init();
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string Original = richTextBox1.Text;// "盘古分词demo2";
Segment segment = new Segment();
ICollection < WordInfo > words = segment.DoSegment(Original);
string strs = "";
foreach (WordInfo v in words)
{
strs += v.ToString() + "\r\n";
}
richTextBox2.Text = strs;
}
}
}
PanGu.xml存储于应用程序同一个目录中,Dict.dct也存储于这个目录中,并已经在PanGu.xml里修改了字典的路径。