网站建设 科目,我要申请邮箱,建设企业营销型网站,深圳公关公司推荐乐云seofunction [count,tf,idf,weight]tfidf(docs,term)%docs--input documents#xff0c;cell型%term-- keywords也就是特征词提取,cell型%output:count--存放各个关键词出现的频率在整个文档中% wordnum--存放文档总的词汇数%测试用例%*****************************************…function [count,tf,idf,weight]tfidf(docs,term)%docs--input documentscell型%term-- keywords也就是特征词提取,cell型%output:count--存放各个关键词出现的频率在整个文档中% wordnum--存放文档总的词汇数%测试用例%*****************************************************************%clear all%doc1www washingtonpost com wp-adv mediacenter images wpni skin2 jpg;%doc2www washingtonpost com wp-adv mediacenter images about us welcome gif;%doc3media washingtonpost com wp-adv mediacenter images wpni mediakit hdr top gif;%doc4www washingtonpost com wp-adv mediacenter html research demographics html;%docs{doc1,doc2,doc3,doc4};%term{washingtonpost,mediacenter,images};%%*************************************************************************Ldocslength(docs);Ltermlength(term);tfzeros(Ldocs,Lterm);idfzeros(1,Lterm);countzeros(Ldocs,Lterm);wordnum[];weightzeros(Ldocs,Lterm);p ;i1;for i1:Ldocsdoccell2mat(docs(i));tabnumfind(docp);Ltablength(tabnum);wordnum(i)Ltab1;k1;for j1:Ltabworddoc(k:tabnum(j)-1);%会少输出最后一个词Lwlength(word);fworddoc((tabnum(Ltab)1):length(doc));%最后一个词Lfwlength(fword);for jj1:Ltermatermcell2mat(term(jj));Latlength(aterm);if LatLw||LatLfwif strcmpi(word,aterm);count(i,jj)count(i,jj)1;if j......(完整源码请下载查看)...展开 收缩