计算所汉语词法分析系统ICTCLAS3.0白皮书

1. Introduction to Chinese Lexical Analyzer ICTCLAS

背景

ICTCLAS介绍

ICTCLAS的性能评估

ICTCLAS大事记

[ICTCLAS3.0 2006 : Chapter 1 - Introduction / 1]

 

背景

  词是最小的能够独立活动的有意义的语言成分,但汉语是以字为基本的书写单位,词语之间没有明显的区分标记,因此,中文词法分析是中文信息处理的基础与关键。所有涉及中文内容处理的系统,如果没有一个好的中文词法分析系统支持,正确率都会受很大影响。汉语自动智能分词是中文信息处理的基础与关键。所有涉及中文内容处理的系统,如果没有一个好的中文词法分析系统支持,正确率都会受很大影响。具体来说,汉语自动智能分词的主要应用领域包括:

  • 中文输入输出技术:连续语音识别、小键盘智能拼音输入、高自然度语音合成、视频文字识别、OCR;自动校对;高性能的汉字编码识别、简繁体智能转换

  • 语言学分析:重复串分析、新词识别、句法分析、篇章分析、语义理解与歧义消解

  • 文本挖掘:自动文摘、命名实体识别与信息抽取、文本分类、文本聚类、信息过滤、自动问答

  • Web挖掘:信息检索(搜索引擎、问答式搜索引擎、面向行业的专业搜索引擎)、查询扩展
  • 智能应用:机器翻译、外语辅助写作、用户兴趣发现、情报分析、垃圾邮件与垃圾短信过滤、有害(垃圾、诈骗、色情、反动)信息监控等

  • 信息增值服务:商情信息自动抽取与统计分析,如房地产信息、产品采购与销售信息

中文词法分析又是一个非常困难的问题,其难点主要体现在以下几方面:

  • 词语切分:由于汉语词语之间没有空格分开,需要从连续的汉字串中正确辨认汉语的词语,常见的歧义现象如:“的确切”可能是“的确/切”或者“的/确切”,“马上”可能是一个词表示很快,也可能是两个词“马/上”表示位置;这些类型的歧义现象在汉语中非常常见,会对汉语词语切分造成极大的干扰

  • 未定义词识别:词典中不可能收录所有的词语,大量的人名、地名、机构名、外来语译名、新词语等等,如“王小山、十里堡、北京计算机研究所、瓦杰帕依、非典”等等,都需要通过软件来自动识别,而在汉语中这些未定义词没有空格作为边界,其组成成分又是有意义的普通汉字,因此识别难度很大

  • 词性标注:汉语中词语兼类情况非常常见,比如说“领导”可以是动词、也可以是名词,要正确标注出每个词的词性,也有很多困难

  虽然汉语词法分析的研究已经有了很长的历史,但在很多应用系统中,速度快的系统分词准确性不能达到实用化要求,准确率高的系统往往使用了大量的知识库,速度不能达到大规模应用的要求。

→『返回TOP

[ICTCLAS3.0 2006 : Chapter 1 - Introduction / 2]

 

ICTCLAS介绍

  中国科学院计算技术研究所在多年研究工作积累的基础上,研制出了汉语词法分析系统ICTCLAS(Institute of Computing Technology, Chinese Lexical Analysis System),主要功能包括中文分词;词性标注;命名实体识别;新词识别;同时支持用户词典。我们先后精心打造五年,内核升级6次,目前已经升级到了ICTCLAS3.0。

  选择ICTCLAS3.0的五大理由:

  1.综合性能最优

  分词系统能否达到实用性要求主要取决于两个因素:分词精度与分析速度,这两者相互制约,难以平衡。大多数系统往往陷入“快而不准,准而不快”的窘境。我们研制出了完美PDAT大规模知识库管理技术(200510130690.3),在高速度与高精度之间取得了重大突破,该技术可以管理百万级别的词典知识库,单机每秒可以查询100万词条,而内存消耗不到知识库大小的1.5倍。基于该技术,ICTCLAS3.0分词速度单机996KB/s,分词精度98.45%,API不超过200KB,各种词典数据压缩后不到3M,是当前世界上最好的汉语词法分析器。

  2.统一的语言计算理论框架

  汉语分词牵涉到汉语分词、未定义词识别、词性标注以及语言特例等多个因素,大多数系统缺乏统一的处理方法,往往采用松散耦合的模块组合方式,最终模型并不能准确有效地表达千差万别的语言现象,而ICTCLAS采用了层叠隐马尔可夫模型(Hierarchical Hidden Markov Model),将汉语词法分析的所有环节都统一到了一个完整的理论框架中,获得最好的总体效果,相关理论研究发表在顶级国际会议和杂志上,从理论上和实践上都证实了该模型的先进性。

  3.全方位支持各种环境下的应用开发

  ICTCLAS全部采用C/C++编写,支持Linux、FreeBSD及Windows系列操作系统,支持C/C++/C#/Delphi/Java等主流的开发语言;

  4.应需而变,量身定做

  所有功能模块均可拆卸组装,ICTCLAS有GB2312和BIG5版本,可分别处理目简繁体中文;支持当前广泛承认的分词和词类标准,包括计算所词类标注集ICTPOS3.0,北大标准、滨州大学标准、国家语委标准、台湾“中研院”、香港“城市大学”;用户可以直接自定义输出的词类标准,定义输出格式;用户可以根据自己的需求,进行量身自助式定做适合自己的分词系统。

  5.国内和国际权威的公开评测、三万客户的认可

  有些公司为了商业目的,关门自测,自称准确度99.50%,没有介绍测试环境和测试方法,封闭测试或者小规模的开放测试准确度100%都不足为奇的,ICTCLAS1.0在国内973专家组组织的评测中活动获得了第一名,ICTCLAS2.0在第一届国际中文处理研究机构SigHan组织的评测中都获得了多项第一名,具体的参见系统评测部分。这些都是权威机构进行大规模现场开放测试的结果,真实可信。

  目前,ICTCLAS已经向国内外的企业和学术机构颁发了30,000多份授权,其中包括3721、NEC、中华商务网、硅谷动力、云南日报等企业,新疆大学、清华大学、华南理工、麻省大学:同时,ICTCLAS广泛地被《科学时报》、《人民日报》海外版、《科技日报》等多家媒体报道。您可以访问Google进一步了解ICTCLAS的应用情况。

  我们欢迎相关领域的工程技术人员、研究人员使用,并提供宝贵意见。

→『返回TOP

[ICTCLAS3.0 2006 : Chapter 1 - Introduction / 3]

 

ICTCLAS的性能评估

ICTCLAS在973评测中的测试结果

2002年7月6日,ICTCLAS参加了国家973英汉机器翻译第二阶段的开放评测,测试结果如下:

领域
词数
SEG
TAG1
RTAG
体育
33,348
97.01%
86.77%
89.31%
国际
59,683
97.51%
88.55%
90.78%
文艺
20,524
96.40%
87.47%
90.59%
法制
14,668
98.44%
85.26%
86.59%
理论
55,225
98.12%
87.29%
88.91%
经济
24,765
97,80%
86.25%
88.16%
总计
208,213
97,58%
87.32%
89.42%

表3. ICTCLAS在973评测中的测试结果

说明:

  1. 数据来源:国家973英汉机器翻译第二阶段评测的评测总结报告
  2. 标注相对正确率RTAG=TAG1/SEG*100%
  3. 由于我们采取的词性标注集和973专家组的标注集有较大出入,所以词性标注的正确率不具可比性
  4. 专家组的开放评测结果表明:基于HHMM的ICTCLAS能实际的解决汉语词法分析问题,和兄弟单位的类似系统对比,ICTCLAS的分词结果表现出色

 

第一届国际分词大赛的评测结果

  为了比较和评价不同方法和系统的性能,第四十一届国际计算语言联合会(41st Annual Meeting of the Association for Computational Linguistics, 41th ACL )下设的汉语特别兴趣研究组(the ACL Special Interest Group on Chinese Language Processing, SIGHAN;www.sighan.org) 于2003年4月22日至25日举办了第一届国际汉语分词评测大赛(First International Chinese Word Segmentation Bakeoff)[28]。报名参赛的分别是来自于大陆、台湾、美国等6个国家和地区,共计19家研究机构,最终提交结果的是12家参赛队伍。

  大赛采取大规模语料库测试,进行综合打分的方法,语料库和标准分别来自北京大学(简体版)、宾州树库(简体版)、香港城市大学(繁体版),台湾“中央院” (繁体版)。每家标准分两个任务(Track):受限训练任务(Close Track)和非受限训练任务(Open Track)。

  ICTCLAS分别参加了简体的所有四项任务,和繁体的受限训练任务。其中在宾州树库受限训练任务中综合得分0.881[28],名列第一;北京大学受限训练任务中综合得分0.951[28],名列第一;北京大学受限训练任务中综合得分0.953[28],名列第二。值得注意的是,我们在短短的两天之内,采取ICTCLAS简体版的内核代码,将多层隐马模型推广到繁体分词当中,同样取得了0.938[28]的综合得分。

 

ICTCLAS3.0的评测结果

我们利用了《人民日报》1998年1月的新闻纯文本语料进行开放测试,ICTCLAS3.0测试的精度与速度如下表所示:

 
开放测试一
开放测试二
开放测试三
功能描述
分词
分词+命名实体与新词识别
分词+命名实体与新词识别+词性标注
测试文件大小
4,092,478 Bytes
4,092,478 Bytes
4,092,478 Bytes
时间(s)
4.094000
6.467561
9.094001
核心数据所占内存
5.5MB
7.2MB
8.9MB
速度
999.63 KB/s
632.77 KB/s
450.02 KB/s
精度
分词精度:96.56%
分词精度:98.13%
分词精度:98.13% 词性标注精度:94.63%


说明:

1. 测试机器配置:CPU: PIV3.0G;内存:512M;

2. 分词精度指的是正确切分的词数占正确结果总词数的百分比;词性标注精度指的是切分与词性标注均正确的词数占正确结果总词数的百分比。

3. 开放测试:指的是测试样本不属于训练样本集合,否则称为封闭测试;封闭测试相当于考试试题都出自于学习过的书本,这种测试并没有实质意义,而往往有一些商家故意混淆视听,以封闭测试来冒充开放测试,制造准确率99.5%的噱头,实际上,通过机械记忆小样本的封闭测试取得100%的精度不存在任何问题。这一点特别提请用户注意。

→『返回TOP

[ICTCLAS3.0 2006 : Chapter 1 - Introduction / 4]

 

ICTCLAS大事记:

  • 2002年7月,在973项目"图像、语音、自然语言理解与知识挖掘"专家组的评测中,在所有参评的系统中,评测得分最高。(分词正确率高达97.58%,参赛单位包括北京大学,清华大学等)

  • 2003年1月7日,获得国家版权局授予的软件著作权登记证书,编号为软著登字005178号)

  • 在2003年4月22日至25日, ICTCLAS参加了第四十一届国际计算语言联合会(41st Annual Meeting of the Association for Computational Linguistics, 41th ACL )下设的汉语特别兴趣研究组(the ACL Special Interest Group on Chinese Language Processing, SIGHAN)举办的第一届国际汉语分词评测大赛[10],在参加的六项比赛中,获得了两项第一名、一项第二名。(参赛单位来自于6个国家和地区的12个系统,包括微软,SYSTRAN, Pennsylvania大学,Berkeley大学,北京大学)

  • 作为计算所的15项免费技术成果之一,被来自于国内外的约30000人次的下载使用。作为中文自然语言处理开放平台的自由软件,受到了广泛的欢迎和关注,在《科学时报》、新浪网、人民日报海外版、中新网、新华网、人民网均有报道[11,12,13,14,15]。我们提供的各种形式研究成果,在学术界和产业界得到了广泛的应用,其中包括:3721、NEC研究院、中华商务网、硅谷动力、云南日报等企业,新疆大学、清华大学、华南理工、麻省大学等研究机构。

  • 2004年7月,推出ICTCLAS2.0;

  • 2005年12月,推出ICTCLAS2.6;

  • 2006年4月,推出ICTCLAS3.0,速度接近1MB/s,精度98.13%;

  • 该系统相关的研究成果在国际会议上发表了4篇论文[1,2,5,8],国际期刊发表了一篇长达32页的论文[3],在《计算机学报》[4]、《计算机研究与发展》[9]、《中文信息学报》[6]等国内的核心期刊上发表论文共三篇,国内会议论文1篇[7]。在学术界和产业界引起了广泛的关注。

→『返回TOP

[ICTCLAS3.0 2006 : API functions 2]

 

2. ICTCLAS API functions

Platforms and Compatibility
API header file
ICTCLAS_Init
ICTCLAS_Exit
ICTCLAS_ParagraphProcessA
ICTCLAS_ParagraphProcess
ICTCLAS_FileProcess
ICTCLAS_SentenceProcess
ICTCLAS_ImportUserDict
ICTCLAS_IsWord
ICTCLAS_GetUniProb

[ICTCLAS3.0 2006 : API functions 2/1]

 

Platforms and Compatibility

OS and program languages support↓

OS supported Win95/98/2000/XP;WinNT;Linux/Unix/FreeBSD,...
Program languages supported C/C++/Java/Delphi/VB,...

 

Libraries and Environment Supported↓

Libraries

Environment Supported

ICTCLAS.dll/ICTCLAS.lib Win95/98/2000/XP/WinNT/...; C/C++/Delphi/VB/...
libICTCLAS.a Linux/Unix/FreeBSD;C/C++
ICTCLAS COM Win95/98/2000/XP/WinNT/...;C/C++/Java/Delphi/VB/...

→『返回TOP

[ICTCLAS3.0 2006 : API functions 2/2]

 

ICTCLAS_Init

Init the analyzer and prepare necessary data for ICTCLAS according the configure file.

bool ICTCLAS_Init(const char * sInitDirPath=NULL);

Routine Required Header
ICTCLAS_Init <ICTCLAS30.h>

Return Value

Return true if init succeed. Otherwise return false.

Parameters

sInitDirPath: Initial Directory Path, where file Configure.xml and Data directory stored.

the default value is NULL, it indicates the initial directory is current working directory path

Remarks

The ICTCLAS_Init function must be invoked before any operation with ICTCLAS. The whole system need call the function only once before starting ICTCLAS. When stopping the system and make no more operation, ICTCLAS_Exit should be invoked to destroy all working buffer. Any operation will fail if init do not succeed.

ICTCLAS_Init fails mainly because of two reasons: 1) Required data is incompatible or missing 2) Configure file missing or invalid parameters. Moreover, you could learn more from the log file ictclas.log in the default directory.

Example

#include "ICTCLAS30.h"
#include <stdio.h>
#include <string.h>

int main(int argc, char* argv[])
{
//Sample1: Sentence or paragraph lexical analysis with only one result
char sSentence[2000],sSentenceResult[5000];
if(!ICTCLAS_Init())
{
printf("Init fails\n");
return -1;
}
printf("Input sentence now('q' to quit)!\n");
scanf("%s",sSentence);
while(_stricmp(sSentence,"q")!=0)
{
ICTCLAS_ParagraphProcess(sSentence,sSentenceResult);
printf("%s\nInput string now('q' to quit)!\n",sSentenceResult);
scanf("%s",sSentence);
}
ICTCLAS_Exit();
return 0;
}

Output

See Also    ICTCLAS_Exit, ICTCLAS configure

→『返回TOP

[ICTCLAS3.0 2006 : API functions 2/3]

 

ICTCLAS_Exit

Exit the program and free all resources and destroy all working buffer used in ICTCLAS.

bool ICTCLAS_Exit();

Routine Required Header
ICTCLAS_Exit <ICTCLAS30.h>

Return Value

Return true if succeed. Otherwise return false.

Parameters

none

Remarks

The ICTCLAS_Exit function must be invoked while stopping the system and make no more operation. And call ICTCLAS_Init function to restart ICTCLAS.

Example

#include "ICTCLAS30.h"
#include <stdio.h>
#include <string.h>

int main(int argc, char* argv[])
{
//Sample1: Sentence or paragraph lexical analysis with only one result
char sSentence[2000],sSentenceResult[5000];
if(!ICTCLAS_Init())
{
printf("Init fails\n");
return -1;
}
printf("Input sentence now('q' to quit)!\n");
scanf("%s",sSentence);
while(_stricmp(sSentence,"q")!=0)
{
ICTCLAS_ParagraphProcess(sSentence,sSentenceResult);
printf("%s\nInput string now('q' to quit)!\n",sSentenceResult);
scanf("%s",sSentence);
}
ICTCLAS_Exit();
return 0;
}

Output

See Also   ICTCLAS_Init

→『返回TOP

[ICTCLAS3.0 2006 : API functions 2/4]

 

ICTCLAS_ParagraphProcessA

ICTCLAS_API const result_t * ICTCLAS_ParagraphProcessA(const char *sParagraph,int *pResultCount);

Routine Required Header
ICTCLAS_ParagraphProcessA <ICTCLAS30.h>

Return Value

the pointer of result vector, it is managed by system, user cannot alloc and free it

struct result_t{
int start; //start position,词语在输入句子中的开始位置
int length; //length,词语的长度
unsigned char POS_id;//word type,词性ID值,可以快速的获取词性表
int word_ID; //如果是未登录词,设成0或者-1
};
Parameters

sParagraph: The source paragraph
pResultCount: pointer to result vector size

Remarks

The ICTCLAS_ParagraphProcessA function works properly only if ICTCLAS_Init succeeds.

Example

#include "ICTCLAS30.h"
#include <stdio.h>
#include <string.h>

int main(int argc, char* argv[])
{
//Sample1: Sentence or paragraph lexical analysis with only one result
char sSentence[2000];
const result_t *pVecResult;
int nCount;
if(!ICTCLAS_Init())
{
printf("Init fails\n");
return -1;
}
printf("Input sentence now!\n");
scanf("%s",sSentence);
while(_stricmp(sSentence,"q")!=0)
{
pVecResult=TGWS_ParagraphProcessA(sInput,&nCount);
for (int i=0;i<nCount;i++)
{
printf("Start=%d Length=%d Word_ID=%d POS_ID=%d\n",
pVecResult[i].start,
pVecResult[i].length,
pVecResult[i].word_ID,
pVecResult[i].POS_id
);
}
}
ICTCLAS_Exit();
return 0;
}

Output

See Also  ICTCLAS_Init, ICTCLASConfigure

→『返回TOP

[ICTCLAS3.0 2006 : API functions 2/5]

 

ICTCLAS_ParagraphProcess

Process a paragraph, and return the result buffer pointer
const char * ICTCLAS_ParagraphProcess(const char *sParagraph);

Routine Required Header
ICTCLAS_ParagraphProcess <ICTCLAS30.h>

Return Value

Return the pointer of result buffer.

Parameters

sParagraph: The source paragraph
Remarks

The ICTCLAS_ParagraphProcess function works properly only if ICTCLAS_Init succeeds.

Example

#include "ICTCLAS30.h"
#include <stdio.h>
#include <string.h>

int main(int argc, char* argv[])
{
//Sample1: Sentence or paragraph lexical analysis with only one result
char sSentence[2000];
const char *sSentenceResult;
if(!ICTCLAS_Init())
{
printf("Init fails\n");
return -1;
}
printf("Input sentence now('q' to quit)!\n");
scanf("%s",sSentence);
while(_stricmp(sSentence,"q")!=0)
{
sSentenceResult=ICTCLAS_ParagraphProcess(sSentence);
printf("%s\nInput string now('q' to quit)!\n",sSentenceResult);
scanf("%s",sSentence);
}
ICTCLAS_Exit();
return 0;
}

Output

See Also  ICTCLAS_ParagraphProcessA, ICTCLAS_Init, ICTCLAS Configure

→『返回TOP

[ICTCLAS3.0 2006 : API functions 2/6]

 

ICTCLAS_FileProcess

Process a text file

bool ICTCLAS_FileProcess(const char *sSourceFilename,const char *sResultFilename);

Routine Required Header
ICTCLAS_FileProcess <ICTCLAS30.h>

Return Value

Return true if processing succeed. Otherwise return false.

Parameters

sSourceFilename: The source file name to be analysized;
sResultFilename: The result file name to store the results.

Remarks

The ICTCLAS_FileProcess function works properly only if ICTCLAS_Init succeeds.

The output format is customized in ICTCLAS configure.

Example

#include "ICTCLAS30.h"

int main(int argc, char* argv[])
{
//Sample2: File text lexical analysis

if(!ICTCLAS_Init())
{
printf("Init fails\n");
return -1;
}
printf("Input sentence now('q' to quit)!\n");
ICTCLAS_FileProcess("Test.txt","Test_result.txt");
ICTCLAS_Exit();
return 0;
}

Output

See Also  ICTCLAS_Init, ICTCLAS Configure

→『返回TOP

[ICTCLAS3.0 2006 : API functions 2/7]

[ICTCLAS3.0 2006 : API functions 2/8]

 

ICTCLAS_ImportUserDict

Import user-defined dictionary from a text file.

bool unsigned int ICTCLAS_ImportUserDict(const char *sFilename);

Routine Required Header
ICTCLAS_ImportUserDict <ICTCLAS30.h>

Return Value

The number of lexical entry imported successfully

Parameters

sFilename: Text filename for user dictionary

Remarks

The ICTCLAS_ImportUserDict function works properly only if ICTCLAS_Init succeeds.

The text dictionary file foramt see User-defined Lexicon.

You only need to invoke the function while you want to make some change in your customized lexicon or first use the lexicon. After you import once and make no change again, ICTCLAS will load the lexicon automatically if you set UserDict "on" in the configure file. While you turn UserDict "off", user-defined lexicon would not be applied.

Example

#include <string.h>

int main(int argc, char* argv[])
{
//Sample1: Sentence or paragraph lexical analysis with only one result
char sSentence[2000]="张华平于1978年3月9日出生于江西省波阳县。",sSentenceResult[5000];
if(!ICTCLAS_Init())
{
printf("Init fails\n");
return -1;
}
//Sample4: User-defined dictionary
sResult=ICTCLAS_ParagraphProcessA("1989年春夏之交的政治风波1989年政治风波24小时降雪量24小时降雨量863计划ABC防护训练APEC会议BB机BP机C2系统C3I系统C3系统C4ISR系统C4I系统CCITT建议");
printf("Before Adding User-defined lexicon, the result is:\n%s\n",sResult);
unsigned int nItems=ICTCLAS_ImportUserDict("Data/UsrLexicon.txt");//Import user-defined dictionary
printf("%d user-defined lexical entries added!\n",nItems);
sResult=ICTCLAS_ParagraphProcessA("1989年春夏之交的政治风波1989年政治风波24小时降雪量24小时降雨量863计划ABC防护训练APEC会议BB机BP机C2系统C3I系统C3系统C4ISR系统C4I系统CCITT建议");
printf("After Adding User-defined lexicon, the result is:\n%s\n",sResult);
ICTCLAS_Exit();
return 0;
}

Output

#include "ICTCLAS30.h"
#include <stdio.h>
Before Adding User-defined lexicon, the result is:
1989年/t 春/tg 夏/tg 之/uzhi 交/ng 的/ude1 政治/n 风波/n 1989年/t 政治/n 风波/n
24/m 小时/n 降雪/vn 量/n 24/m 小时/q 降雨量/n 863/m 计划ABC防护训练APEC会议BB机B
P机C2系统C3I系统C3系统C4ISR系统C4I/nt 系统/n CCITT/x 建议/n
14321 user-defined lexical entries added!
After Adding User-defined lexicon, the result is:
1989年春夏之交的政治风波/n 1989年政治风波/n
24小时降雪量/n 24小时降雨量/n 863计划/n ABC防护训练/vn APE
C会议/nz BB机/n BP机/n C2系统/n C3I系统/n C3系统/n C4ISR系统/n C4I系统/n CCITT建
议/t

See Also  ICTCLAS_Init, ICTCLAS Configure User-defined Lexicon

→『返回TOP

[ICTCLAS3.0 2006 : API functions 2/9]

 

ICTCLAS_IsWord

Search in the lexicon, and determin whether the word is listed in the core lexicon.

bool ICTCLAS_IsWord(const char *sWord);

Routine Required Header
ICTCLAS_IsWord
<ICTCLAS30.h>

Return Value

Return true if exists. Otherwise return false.

Parameters

sWord:word to be searched.

Remarks

The ICTCLAS_IsWord function works properly only if ICTCLAS_Init succeeds.

Example

#include "ICTCLAS30.h"
#include <stdio.h>

int main(int argc, char* argv[])
{
if(!ICTCLAS_Init())
{
printf("Init fails\n");
return -1;
}
printf("Input sentence now('q' to quit)!\n");
bool bRtn=ICTCLAS_IsWord("人民");//Judge whether the word exists in the core dictionary
printf("人民");
if(!bRtn)
printf(" not");
printf(" exists\n");

bRtn=ICTCLAS_IsWord("人民王");
printf("人民王");
if(!bRtn)
printf(" not");
printf(" exists\n");
ICTCLAS_Exit();
return 0;
}

Output

人民 exists

人民王 not exists

→『返回TOP

[ICTCLAS3.0 2006 : API functions 2/10]

 

ICTCLAS_GetUniProb

Get the unigram probability of a given word

float ICTCLAS_GetUniProb(const char *sWord);

Routine Required Header
ICTCLAS_GetUniProb
<ICTCLAS30.h>

Return Value

Return the unigram probability after some simple smoothing technique.

Parameters

sWord:word to be queried.

Remarks

The ICTCLAS_GetUniProb function works properly only if ICTCLAS_Init succeeds.

Example

#include "ICTCLAS30.h"
#include <stdio.h>

int main(int argc, char* argv[])
{
if(!ICTCLAS_Init())
{
printf("Init fails\n");
return -1;
}
printf("Input sentence now('q' to quit)!\n");
float fProb=ICTCLAS_IsWord("人民");//Retrieval the unigram probablity
printf("Unigram probability of 人民 is %f\n ",fProb);
ICTCLAS_Exit();
return 0;
}

Output
[omit]

See Also  ICTCLAS_Init

→『返回TOP

[ICTCLAS3.0 2006 : Configure 3]

 

3. ICTCLAS Configure

ICTCLAS Configure is stored in Configure.xml. The parameter lists as follows:

<?xml version="1.0" encoding="GB2312"?>
<ICTCLAS>
<DataPath>Data</DataPath>
<!-- Data文件夹路径 -->
<TagSet>ICTCLAS.map</TagSet>
<!--词性标注集映射文件 -->
<UserDict>Off</UserDict>
<!--On:User Dictionary applied; Off: not applied; -->
<Log>On</Log>
<!--On, Off;例如:Off: 关闭日志功能;On: 打开日志功能 -->
<version>3.0</version><!--系统版本号 -->
<Modify>2005-12-27</Modify><!--系统最近修订时间 -->
<Lexicon>2005-10-10</Lexicon><!--词典最近修订时间 -->
</ICTCLAS>

→『返回TOP

[ICTCLAS3.0 2006 : Example 4]

 

4. ICTCLAS Example

C/C++ Example
C# Example
How to compile ICTCLAS lib in Linux/Unix/ FreeBSD
ASP Example
Delphi Example
Java Example

[ICTCLAS3.0 2006 : ICTCLAS example 4/1]

C/C++ example

Example

#include <stdio.h>

#include <string.h>

#include "ICTCLAS30.h"

int main(int argc, char* argv[])

{

//Sample1: Sentence or paragraph lexical analysis with only one result

char sSentence[2000];

const char *sResult;

if(!ICTCLAS_Init())

{

printf("Init fails\n");

return -1;

}

printf("Input sentence now!\n");

scanf("%s",sSentence);

while(_stricmp(sSentence,"q")!=0)

{

sResult=ICTCLAS_ParagraphProcessA(sSentence);

printf("%s\nInput string now!\n",sResult);

scanf("%s",sSentence);

}

 

//Sample2: File segmentation and POS tagging

ICTCLAS_FileProcess("G:/ICTCLAS26/Test/Test.txt","G:/ICTCLAS26/Test/Test_result.txt");

//Sample3:Judge whether the word exists in the core dictionary

bool bRtn=ICTCLAS_IsWord("人民");

printf("人民");

if(!bRtn)

printf(" not");

printf(" exists\n");

 

bRtn=ICTCLAS_IsWord("人民王");

printf("人民王");

if(!bRtn)

printf(" not");

printf(" exists\n");

 

//Sample3: User-defined dictionary

sResult=ICTCLAS_ParagraphProcessA("1989年春夏之交的政治风波1989年政治风波24小时降雪量24小时降雨量863计划ABC防护训练APEC会议BB机BP机C2系统C3I系统C3系统C4ISR系统C4I系统CCITT建议");

printf("Before Adding User-defined lexicon, the result is:\n%s\n",sResult);

unsigned int nItems=ICTCLAS_ImportUserDict("Data/UsrLexicon.txt");//Import user-defined dictionary

printf("%d user-defined lexical entries added!\n",nItems);

sResult=ICTCLAS_ParagraphProcessA("1989年春夏之交的政治风波1989年政治风波24小时降雪量24小时降雨量863计划ABC防护训练APEC会议BB机BP机C2系统C3I系统C3系统C4ISR系统C4I系统CCITT建议");

printf("After Adding User-defined lexicon, the result is:\n%s\n",sResult);

 

ICTCLAS_Exit();

return 0;

}

See ICTCLAS API; Platforms and Compatibility

→『返回TOP

 

C# example

Example

using System;
using System.IO;

using System.Runtime.InteropServices;

namespace ICTCLASDemo
{
using System;
using System.IO;

using System.Runtime.InteropServices;

namespace ICTCLASDemo
{
/// <summary>
/// ICTCLASDll 的摘要说明。
/// </summary>
class ICTCLASDll
{
[DllImport("ICTCLAS30.dll",CharSet=CharSet.Ansi)]
public static extern bool ICTCLAS_Init(String sInitDirPath);

[DllImport("ICTCLAS30.dll",CharSet=CharSet.Ansi)]
public static extern String ICTCLAS_ParagraphProcess(String sParagraph);

[DllImport("ICTCLAS30.dll",CharSet=CharSet.Ansi)]
public static extern bool ICTCLAS_Exit();

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
if(!ICTCLAS_Init(null))
{
System.Console.WriteLine("Init ICTCLAS failed!");
return;
}
System.Console.WriteLine("Input Sentence Now!(q to quit)\n");
String sInput = System.Console.ReadLine();
String pResult;
//音乐会上还演奏了小提琴协奏曲《梁山伯与祝英台》、
while (sInput.CompareTo("q")!=0)
{
pResult = ICTCLAS_ParagraphProcess(sInput);
System.Console.WriteLine("Resut: %s\nInput Sentence Now!(q to quit)\n",pResult);
sInput = System.Console.ReadLine();
}
ICTCLAS_Exit();
}
}
}
}

See ICTCLAS API; Platforms and Compatibility

→『返回TOP

[ICTCLAS3.0 2006 : ICTCLAS example 4/2]

 

How to compile ICTCLAS lib in Linux/Unix/ FreeBSD

You must program the application with C/C++. Example as in the previous section

With the ICTCLAS lib libICTCLAS.a, you could compile the program (i.e. file name Example.cpp) with the following Makefile.

Makefile

test: Example.cpp ICTCLAS30.h
g++ Example.cpp -L. -lICTCLAS -Wstrict-prototypes -Wall -Wunused -O3 -o test

See ICTCLAS API; Platforms and Compatibility

→『返回TOP

[ICTCLAS3.0 2006 : ICTCLAS example 4/3]

 

ASP example

You must register ICTCLAS com firstly. Example as follows

<%
'测试ICTCLAS组件
dim str
set a=server.CreateObject("zhp_atl.CWordParser")
a.Init()
A.Processing(“岁月的年轮像那黑色的旋转的唱片,在我们每一个人的内心深处,播放着那美丽的旧日情曲。")
str= a.Result
Response.write(str)
a.Exit()
set a =nothing
%>

See ICTCLAS API; Platforms and Compatibility

→『返回TOP

[ICTCLAS3.0 2006 : ICTCLAS example 4/4]

 

Delphi example

procedure TForm1.btnInitClick(Sender: TObject);
begin
if hasInit then exit;
dllHandle:=0;
//将“ICTCLAS.dll”的文件映象映射进调用进程的地址空间,需要指出ICTCLAS.dll的路径
//ICTCLAS.dll在当前路径
dllHandle:=LoadLibrary('ICTCLAS.dll');
if dllHandle=0 then
begin
ShowMessage('初始化失败');
end
else
begin
@initCls:=GetProcAddress(dllHandle,'ICTCLAS_Init'); //
@exitCls:=GetProcAddress(dllHandle,'ICTCLAS_Exit'); //
@processCls:=GetProcAddress(dllHandle,'ICTCLAS_ParagraphProcess');

if (@initCls=nil) then
begin
ShowMessage('调用函数“ICTCLAS_Init”时出错!');
exit;
end;

if (@exitCls=nil) then
begin
ShowMessage('调用函数“ICTCLAS_exit”时出错!');
exit;
end;

if (@processCls=nil) then
begin
ShowMessage('调用函数“ICTCLAS_process”时出错!');
exit;
end;

initCls;
btnCls.Enabled:=true;
btnInit.Enabled:=false;
hasInit:=true;
StatusBar1.Panels[0].Text:='ICTCLAS 初始化成功,您可以进行切分了!';
end;
end;

See ICTCLAS API; Platforms and Compatibility

→『返回TOP

 

JNI Test example (for Java)

public class testICTCLAS
{
static
{
System.loadLibrary("ICTCLAS30");
}
public native static boolean ICTCLAS_Init(String sInitDirPath);
public native static boolean ICTCLAS_Exit();
public native static int ICTCLAS_ImportUserDict(String sFilename);
public native static String ICTCLAS_ParagraphProcess(String sSrc);
public native static double ICTCLAS_FileProcess(String sSourceFilename,StringsResultFilename);

public static void main(String[] args)
{
System.out.println("Begin!");

testICTCLAS test = new testICTCLAS();
if(test.ICTCLAS_Init("")==false)
{
System.out.println("Init Fail!");
return;
}
System.out.println("Init Success!");
String result=test.ICTCLAS_ParagraphProcess("超女纪敏佳深受观众喜爱。禽流感爆发在非典之后。");
System.out.println(result);
test.ICTCLAS_Exit();
}
}

See ICTCLAS API; Platforms and Compatibility

→『返回TOP

[ICTCLAS3.0 2006 : User-defined lexicon/ 5]

 

5. User-defined Lexicon

How to Load/Unload user-defined lexicon
User-defined lexical entry format
How to comment in user-defined lexicon
Sample

如何加载卸载用户词典

第一次加载用户词典或者需要变更用户词典的时候,直接调用 ImportUserDict(const char *sFilename)即可。下次使用同一部用户词典,不需要再调用该函数,如果在配置文件中设置<UserDict>On</UserDict>,系统会自动加载。在配置文件中设置<UserDict>Off</UserDict>,系统会自动将用户词典屏蔽。

用户词典格式


(词 词性)
用户词典词性的说明:
1)所用到的词性标注集,与核心词典词性标注集(可以自行指定)一致
2)如果没有给出词性或者给出的词性不正确,按照名词处理

如何在用户词典中注释


可以在任何地方添加注释内容,注释的方法有:
1)在当前行加上"//",则当前行//后面的内容无效
2)"/*" 至"*/"内容无效,/*必须是每行的开始位置,即:
/*注释内容
kakl
addddddddd*/
注释有效,而
啊 a/*注释内容
kakl
addddddddd*/
注释无效
注意第二种注释方式不支持嵌套

用户词典示例


待加载的用户词典应当是一个文本文件,每行不得超过1000个字节,示例如下

/*1989年春夏之交的政治风波 //政治术语
1989年政治风波
24小时降雪量
24小时降雨量
863计划
ABC防护训练*///前面内容都被注释掉
APEC会议 nz //注释内容:词性为nz
BB机//注释内容:没有给出词性,按照"n"处理
BP机 nzert//词性无效,按照"n"处理
C2系统
C3I系统
C3系统
C4ISR系统
C4I系统
CCITT建议 t

→『返回TOP

[ICTCLAS3.0 2006 : Authors/ 6]

 

6. Authors

 

 

 

 

 

 

 

张华平 博士
中科计算技术转移中心信息智能与信息安全部 总经理
中国科学院计算技术研究所 副研究员
地址:北京市海淀区中关村东路18号财智大厦A座707室 邮编:100083
电话:+86-10-82601206
传真:+86-10-82601206 转 601
Email:zhanghp@software.ict.ac.cn
MSN: pipy_zhang@msn.com;
Homepage: http://lcc.ict.ac.cn/~zhp/
Blog: http://blog.sina.com.cn/m/zhangzihan

Dr. Kevin Zhang (张华平,Zhang Hua-Ping)
Chief Executice Officer,
Information Intelligence and Information Security Division
CAS Computing Technology Transferring Center
Associate Professor,
Institute of Computing Technology
Chinese Academy of Sciences
Address:
Room 707, Build A, Caizhi Tower,
NO. 18, East Road, Zhongguancun, Haidian District
Beijing, P.R.China Zip Code 100083
Tel: +86-10-82601206(Office)
Fax: +86-10-82601206 ext 601(Office)
Email:zhanghp@software.ict.ac.cn
MSN: pipy_zhang@msn.com;
Homepage: http://lcc.ict.ac.cn/~zhp/
Blog: http://blog.sina.com.cn/m/zhangzihan

→『返回TOP

[ICTCLAS3.0 2006 : Related source 7]

 

7.Related source

1. ICTCLAS Beta版本公开源代码

2. 词性标注集说明书 (Part-Of-Speech Set Document)

3. Windows C/C++ API

4. ICTCLAS for Linux

5. ICTCLAS JNI for Java

6. ICTCLAS JAR for Lucene

7. ICTCLAS 繁体版本分词

8. 产品白皮

→『返回TOP

[ICTCLAS3.0 2006 : System log 9]

 

8. 如何激活授权

参照统一的授权激活程序

[ICTCLAS3.0 2006 : Reference 11]

 

9. 部分重点客户

 

[ICTCLAS3.0 2006 : Reference 11]

 

10. Acknowledgments

Hua-Ping give acknowledgements to:

1. Associate Prof. Qun Liu for his guide to Chinese natural language processing, detail assistance in the whole procedures, including ICTCLAS system design and coding.

2. My Ph.D supervisor Shuo Bai for his tutoring and care in the last years; My M. Sc supervisor and our division director Xueqi Cheng for his help and support from my first day in the software division.

3. Prof. Shiwen Yu of Peking University for the training corpus.

4. Hongkui Yu for his excellent work in implement of organization recognition using role model, and some more trivial work including corpus transformation.

5. Gang Zou for his excellent work in automatic assessment on lexical result.

6. Thanks the support and instructive discussion from Dr. Bin Wang, Dr. Jian Sun, Mr. Weihua Luo, Jifeng Li and other colleagues in LLC(large content computing) group.

7. All ICTCLAS users (no less than 30,000 till now) for their toleration, active and helpful reaction. Especially thanks the commercial entities for the practical advice and new requirement.

8. Huaping Zhang would especially express gratitude to his graceful girl friend Feifei and her family for their encouragement during the hard work.

→『返回TOP

[ICTCLAS3.0 2006 : Reference 11]

 

11 参考文献

[1]ZHANG Hua-Ping et al; Chinese Lexical Analysis Using Hierarchical Hidden Markov Model , Second SIGHAN workshop affiliated with 41th ACL; Sapporo Japan, July, 2003, pp. 63-70

[2]ZHANG Hua-Ping et al; HHMM-based Chinese Lexical Analyzer ICTCLAS, Second SIGHAN workshop affiliated with 41th ACL; Sapporo Japan, July, 2003, pp. 184-187

[3]ZHANG Hua-Ping, LIU Qun, et al. Chinese Name Entity Recognition Using Role Model. Special issue "Word Formation and Chinese Language processing" of the International Journal of Computational Linguistics and Chinese Language Processing, vol.8, No.2, 2003, pp. 29-60

[4]ZHANG Hua-Ping, LIU Qun; Automatic Recognition of Chinese Person Name based on Role-Tagging;(accepted) Chinese Journal of Computer, 2003

[5]Kevin Zhang(Zhang Hua-Ping), Qun Liu, Hao Zhang, Xueqi Cheng. Automatic Recognition of Chinese Unknown Words Based on Role Tagging, First SIGHAN affiliated with 19th COLING, 2002-9 pp71-77;

[6]ZHANG Hua-Ping, LIU Qun. Model of Chinese Words Rough Segmentation Based on N-Shortest-Paths Method; Journal of Chinese Information Processing, 2002-9, Vol.16(5):pp.1-pp.7;

[7]ZHANG Hua-Ping, LIU Qun. Automatic Recognition of Chinese Person Name based on Role-Tagging, Proc. of 7th Conference of Computer Science for Graduate Student in CAS, 2002-7, Si Chuan

[8]YU Hong-Kui, ZHANG Hua-Ping, etc. Automatic Recognition of Chinese Organization based on Role-Tagging, Proc. of 20th International Conference on Computer Processing of Oriental Languages , 2003-8, pp79-87, ShenYang

[9]LIU Qun, ZHANG Hua-Ping; Chinese Lexical Analysis Using Hierarchical Hidden Markov Model;(accepted) Chinese Journal of Computer Research and Development, 2003

[10]Richard Sproat, Thomas Emerson. The First International Chinese Word Segmentation Bakeoff, First SIGHAN Workshop attached with the ACL2003, 2003.7, pp.133-143

[11] 张璋, 中文自然语言资源共享开辟新路, 科学时报,2003.2.21

[12] 张璋, 中文LDC推动汉语资源共享, 科学时报,2003.1.29

[13] 中新网, 中文语言资源共享, 中国科学家推出处理新技术, 2002

[14] 新华网, 中科院15项产品和技术免费转让引起关注, 2002.9. 9

[15] 新浪网,中科院科研成果免费送达中小企业

→『返回TOP

[ICTCLAS3.0 2006 : Manual log 8]

12. Manual Log

1. Kevin Zhang 2003-11-27 Manual Version 1.0 created

2..Kevin Zhang 2003-11-27 Manual Version 1.6 modified; adding new API functions, user-defined lexicon, manual log and system log, adding ICTPOS3.0 tagset

3. Kevin Zhang 2006-12-1 Manual Version 2.0 modified;

→『返回TOP

 

Copyright © 2001-2006 中科计算技术转移中心 中国科学院计算技术研究所 版权所有 All Rights Reserved
Last Update: 2007-01-23 17:18有任何建议或问题请联系张华平