NICTCLAS:词法分析系统ICTCLAS的.NET版(源码提供下载)
Posted on 2006-05-03 03:47 microsoft001 阅读(11118) 评论(106) 编辑 收藏 举报再次声明,请下载的朋友使用VS2005打开和
安装.NET框架2.0。源码为C++/CLI,不是C#,
请不要再发邮件问我相关问题。谢谢合作。
源码在文末下载
NICTCLAS是大名鼎鼎的中科院计算所语词法分析系统ICTCLAS免费版的.NET包装版本,在原有免费EXE源码的基础上使用C++/CLI封装成NICTCLAS.dll,将原CResult类改写成NICTCLAS managed class,并为适应VC8编译对源码做了少许改动,当然还有N个因为strcpy之类的警告因为实在太多干脆不予理会。如有错漏请不吝指正。
NICTCLAS做了一定程度的简化,接口非常简单,普通分词应用足够了,这里提供C#执行程序调用示例。词库文件下载解压请放在对应NICTCLAS.dll的Data目录下。如果需要在ASP.NET中调用请自行修改代码中词典文件路径。
调用代码示例
public partial class Form1 : Form
{
NICTCLAS nictclas;
public Form1()
{
InitializeComponent();
try
{
nictclas = new NICTCLAS();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
nictclas.OperateType = eOperateType.OnlySegment;
else if (radioButton2.Checked)
nictclas.OperateType = eOperateType.FirstTag;
else if (radioButton3.Checked)
nictclas.OperateType = eOperateType.SecondTag;
if (radioButton4.Checked)
nictclas.OutputFormat = eOutputFormat.PKU;
else if (radioButton5.Checked)
nictclas.OutputFormat = eOutputFormat._973;
else if (radioButton6.Checked)
nictclas.OutputFormat = eOutputFormat.XML;
DateTime start = DateTime.Now;
string result = "";
//***************分词处理调用
nictclas.ParagraphProcessing(textBox1.Text,ref result);
DateTime finish = DateTime.Now;
TimeSpan t = (TimeSpan)(finish - start);
textBox3.Text = t.TotalMilliseconds.ToString() + "ms";
textBox2.Text = result;
}
}
{
NICTCLAS nictclas;
public Form1()
{
InitializeComponent();
try
{
nictclas = new NICTCLAS();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
nictclas.OperateType = eOperateType.OnlySegment;
else if (radioButton2.Checked)
nictclas.OperateType = eOperateType.FirstTag;
else if (radioButton3.Checked)
nictclas.OperateType = eOperateType.SecondTag;
if (radioButton4.Checked)
nictclas.OutputFormat = eOutputFormat.PKU;
else if (radioButton5.Checked)
nictclas.OutputFormat = eOutputFormat._973;
else if (radioButton6.Checked)
nictclas.OutputFormat = eOutputFormat.XML;
DateTime start = DateTime.Now;
string result = "";
//***************分词处理调用
nictclas.ParagraphProcessing(textBox1.Text,ref result);
DateTime finish = DateTime.Now;
TimeSpan t = (TimeSpan)(finish - start);
textBox3.Text = t.TotalMilliseconds.ToString() + "ms";
textBox2.Text = result;
}
}
C#调用程序截图
执行文件下载
(不好意思,下载之前帮我点下增加一点下书的积分吧。
得益网的链接http://www.netyi.net/in.asp?id=edison1024,点击后出现下载地址)