c++程序自然语言处理,自然语言处理:文本分类程序(含开源代码)

a4c26d1e5885305701be709a3d33442f.png

主要数据结构:

参见common.h

Preprocess p(beginIndex,endIndex);//文本分类预处理类

DICTIONARY mymap;//词典

CONTINGENCY contigencyTable;//词汇类别共现关系词典

FeatureWeight mymapweight;//词汇及权重

DOCMATRIX_1 trainingSet;//训练集VSM模型

DOCMATRIX_1 testingSet;//测试集VSM模型

Preprocess类的主要工作函数

词典相关:

p.ConstructDictionary(mymap,seg,trainCorpusTable);

p.SaveDictionary(mymap,dictaddress);

p.LoadDictionary(mymap,dictaddress);

词典类别共现关系相关:

p.GetContingencyTable(mymap,labels,contigencyTable,trainCorpusTable);

p.SaveContingencyTable(contigencyTable,contigencyaddress);

p.LoadContingencyTable(contigencyTable,contigencyaddress);

特征词选择相关:

//

p.ChiSquareFeatureSelection(labels,mymap,mymapweight,contigencyTable,weightaddress);

p.ChiFitFeatureSelection(labels,mymap,mymapweight,contigencyTable,weightaddress);

p.InformationGainFeatureSelection(labels,mymap,mymapweight,contigencyTable,weightaddress);

p.PointWiseMIFeatureSelection(labels,mymap,mymapweight,contigencyTable,weightaddress);

建立VSM模型相关

(1)建立ARFF数据格式的测试集VSM模型

p.WriteHeadArff(testvsmaddress,keywordaddress,labels);

p.GetManyVSM(1,2676,testCorpusTable,mymap,testingSet,keywordaddress);

p.WriteDataBodyArff(testingSet,testCorpusTable,testvsmaddress,featuredimension[i]);

(2)建立ARFF数据格式的训练集VSM模型

p.WriteHeadArff(trainvsmaddress,keywordaddress,labels);

p.VSMConstruction(mymap,trainingSet,keywordaddress);

p.WriteDataBodyArff(trainingSet,trainCorpusTable,trainvsmaddress,featuredimension[i]);

注意事项:

i中英停用词表:分别是程序目录下的 stopwords.txt,

estopwords.txt。根据处理文本的不同,请手动定位MakeStopSet函数,对其所load的停用词表名称进行相应的修改。

ii程序的正确运行需要安装boost库,boost的安装方法请见:

iii关于文本分类的更详细的介绍流程请见:

程序的分词调用ICTCLAS,如果程序调用提示过期,请到ictclas官方网站下载更新。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值