CLucene+ICTCLAS中文分词整合

计算所汉语词法分析系统ICTCLAS,有关它的信息 http://sewm.pku.edu.cn/QA/reference/ICTCLAS/FreeICTCLAS/

一、生成动态库DLL或静态库Lib文件,并写好接口函数

bool ICT_INIT(int outputFormat,int operateType);
void ICT_FILEPROC(char *sFileName);
void ICT_SPLITWORDS(char *paremeter,char * &pResult);

二、参考lucene接口的实现,现在clucene的ictclas接口
/***********************************
 ** ictclas.h
/***********************************/
#ifndef _lucene_util_Ictclas_
#define _lucene_util_Ictclas_
#if defined(_LUCENE_PRAGMA_ONCE)
# pragma once
#endif
CL_NS_DEF(util)
class ICTCLAS
{
private: 
 static ICTCLAS *instance;
public:
 ICTCLAS();
 static ICTCLAS* getInstance();
 static void doFile(const char *fileName);
 static void doWord(char *sParagraph,char* &m_sResult);
 ~ICTCLAS();
};
CL_NS_END
#endif

/***********************************
 ** ictclas.cpp
/***********************************/
#include "Ictclas.h"
#ifndef _lucene_analysis_standard_StandardIctclas_
#define _lucene_analysis_standard_StandardIctclas_
#pragma comment(lib,"ICTCLASSLIB.lib")
//#define DLLIMPORT _declspec(dllimport)
#define DLLEXPORT __declspec( dllexport )
DLLEXPORT bool init(int,int);
DLLEXPORT void fileProcess(const char *fileName);
DLLEXPORT void splitWords(char *sParagraph,char* &m_sResult);
#endif
CL_NS_DEF(util)
ICTCLAS* ICTCLAS::instance=NULL;
ICTCLAS::ICTCLAS()
{
 init(0,0);
}
ICTCLAS* ICTCLAS::getInstance(){
 if (instance==NULL)
 {
   instance = new ICTCLAS();
 }
 return instance;
}
void ICTCLAS::doFile(const char *fileName){
 fileProcess(fileName);
}
void ICTCLAS::doWord(char *sParagraph,char* &m_sResult){
 splitWords(sParagraph,m_sResult);
}
ICTCLAS::~ICTCLAS(){
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值