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做了一定程度的简化,接口非常简单,普通分词应用足够了,这里提供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;
}
}
C#调用程序截图
执行文件下载
https://files.cnblogs.com/edison1024/NICTCLAS_Release.rar
程序文件(包括C++/CLI C#源码和工程文件)下载地址
https://files.cnblogs.com/edison1024/ictclas.rar
词典文件下载地址
https://files.cnblogs.com/edison1024/Data.rar
ICTCLAS官方免费原版下载地址
http://www.ict.ac.cn/freeware/003_ictclas.asp


浙公网安备 33010602011771号