基于朴素贝叶斯分类器的文本分类算法(C语言)
txt两个人吵架,先说对不起的人,并不是认输了,并不是原谅了
他只是比对方更珍惜这份感情
#include#include#include//_getcwd(),_chdir()#include//_MAX_PATH,system()#include//_finddata_t,_findfirst(),_findnext(),_findclose()charvocabulary[1000][20];/*声明公有二维数组,用来存储分割好的单词*//*=================将要分类的文本分割成单词存储在二维数组vocabulary中================*///@输入参数:要分类的文本//@输出参数:该文本中总单词数intSplitToWord(chartext[]){inti=0;charseps[]=",
\n";/*定义单词的分隔符*/char*substring;/******利用分隔符将文本内容分割成单词并存储******/substring=strtok(text,seps);while(substring
=NULL){strcpy(vocabulary[i],substring);//将单词存储到vocabulary数组中substring=strtok(NULL,seps);i++;}returni;//返回一共多少个单词}/*===============================计算该目录下的文件数================================*///@输入参数:无//@输出参数:该目录下
txt文件数intCountDirectory(){intcount=0;//txt文件计数器longhFile;_finddata_tfileinfo;/********查找