NLPIR分词系统(ICTCLAS 2013)在VS 2013中使用

NLPIR汉语分词系统(又名ICTCLAS 2013),主要功能包括中文分词;词性标注;命名实体识别;用户词典功能;支持GBK编码、UTF8编码、BIG5编码。

0.官方网站http://ictclas.nlpir.org/注意:非商用版本每个月需要更新License,更新License地址为https://github.com/NLPIR-team/NLPIR,目录../NLPIR/License/license for a month/NLPIR-ICTCLAS分词系统授权.rar。用解压好的文件NLPIR.user替换原文件夹Data中的NLPIR.user文件即可。商用版本无需更新但需联系作者。

1.在该网址下载分词系统文件http://ictclas.nlpir.org/downloads。解压文件后需要用到的是Data文件夹、Include文件夹下的NLPIR.h、..\lib\win32文件夹下的NLPIR.dll和NLPIR.lib两个文件。

2.Data、NLPIR.h、NLPIR.dll和NLPIR.lib均拷贝至程序工程目录下。Data文件夹内有分词用到的词典,在该目录下可以直接使用。NLPIR.dll需要配置环境变量:工程属性-->配置属性-->调试-->环境,将DLL所在文件夹包括进去即可。

添加NLPIR.lib有两种方法:①#pragma comment(lib,"NLPIR.lib") ②选择工程属性-->配置属性-->链接器-->输入->附加依赖项,在其中加入lib文件名即可。

添加NLPIR.h,工程属性-->配置属性-->VC++目录-->包含目录,将NLPIR.h所在的文件夹包含进去,最后加上#include "NLPIR.h"即可。

3.编写程序,贴上一段测试代码供参考:

#include "stdafx.h"  
  
#include "iostream"  
#include "string"  
  
using namespace std;  
  
#include "NLPIR.h"  
#pragma comment(lib, "NLPIR.lib")  
  
  
int _tmain(int argc, _TCHAR* argv[])  
{  
    if(!NLPIR_Init())   
    {  
        printf("Init fails\n");  
        return -1;  
    }  
  
    const char *participle_result;  
  
    unsigned int add_dic_items = NLPIR_ImportUserDict("user_dic.txt");//Import user dictionary  
    printf("%d user-defined lexical entries added!\n", add_dic_items);  
  
    const char *sentence = "[整租出租]宣武门西大街4号楼二居整租[整套出租]媒体村天居园大两居[整套出租]媒体村天居园大两居";  
  
    cout << "===============NLPIR_ParagraphProcess==================" << endl;  
    participle_result = NLPIR_ParagraphProcess(sentence,1);  
    cout << participle_result << endl;  
    cout << "=================================" << endl;  
  
  
    cout << "==============NLPIR_GetFileNewWords===================" << endl;  
    const char * get_file_new_words = NLPIR_GetFileNewWords("test.txt");  
    cout << get_file_new_words << endl;  
    cout << "=================================" << endl;  
  
  
    cout << "===============NLPIR_GetKeyWords==================" << endl;  
    const char * get_key_words = NLPIR_GetKeyWords(sentence);  
    cout <<  get_key_words << endl;  
    cout << "=================================" << endl;  
  
  
    cout << "===============NLPIR_GetFileKeyWords==================" << endl;  
    const char * get_file_key_words = NLPIR_GetFileKeyWords("test.txt");  
    cout << get_file_key_words << endl;  
    cout << "=================================" << endl;  
  
  
    cout << "===============NLPIR_GetNewWords==================" << endl;  
    const char * get_new_words = NLPIR_GetNewWords(sentence);  
    cout << get_new_words << endl;  
    cout << "=================================" << endl;  
  
  
    NLPIR_Exit();  
  
    return 0;  
}  


 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值