欢迎来到天天文库
浏览记录
ID:19934665
大小:16.61 KB
页数:5页
时间:2018-10-08
《计算信息检索评价指标pr的源程序》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、packagefileAndStringOperate;importjava.io.BufferedReader;importjava.io.File;importjava.io.FileOutputStream;importjava.io.FileReader;importjava.io.FileWriter;importjava.io.IOException;importjava.io.OutputStream;publicclassReadFileToString{publicstaticvoidmain(Stri
2、ng[]args)throwsIOException{StringfileData=readtxt("D:\IR\1\JAVA网络爬虫.txt");CountRelatedDocument(fileData);//MyWebRec[]myWebRec=newMyWebRec[2000];ClassifyURL(fileData);}privatestaticStringreadtxt(StringfilePath)throwsIOException{BufferedReaderbr=newBufferedReade
3、r(newFileReader(filePath));Stringstr="";Stringr=br.readLine();while(r!=null){str+=r+"";r=br.readLine();}returnstr;}privatestaticchar[][]readtxtToChar(StringfilePath)throwsIOException{char[][]data=null;intcurrentline=0;BufferedReaderbr=newBufferedReader(newFileR
4、eader(filePath));Stringstr="";Stringr=br.readLine();while(r!=null){str+=r+"";data[currentline++]=str.toCharArray();r=br.readLine();}returndata;}privatestaticintCountRelatedDocument(StringfileData){intcntRelated=0;intcurrentLine=1;intbaiduCnt=0;intbingCnt=0;ints
5、ogouCnt=0;int_360Cnt=0;intState=0;booleanbaiduY[]=newboolean[51];booleanbingY[]=newboolean[51];booleansogouY[]=newboolean[51];boolean_360Y[]=newboolean[51];char[]fileChar=fileData.toCharArray();for(inti=0;i6、='*'){State++;System.out.println("分点:"+currentLine);}if(fileChar[i]=='')currentLine++;if(currentLine%3==0){if(fileChar[i]=='Y'7、8、fileChar[i]=='y'){if(State==1){baiduCnt++;baiduY[currentLine/3]=true;}elseif(State==2){bingCnt++;bingY[currentLine/3-50]=true;//Syste9、m.out.println(currentLine/3-50);}elseif(State==3){sogouCnt++;sogouY[currentLine/3-100]=true;}elseif(State==4){_360Cnt++;_360Y[currentLine/3-150]=true;}cntRelated++;}}}try{CaculatePR(baiduY,bingY,_360Y,sogouY,cntRelated);}catch(Exceptione){e.getMessage();}System.o10、ut.println("cntRelated="+cntRelated);System.out.println("baiduCnt="+baiduCnt);System.out.println("bingCnt="+bingCnt);System.out.println("sohuCnt="+sogouCnt);Sy
6、='*'){State++;System.out.println("分点:"+currentLine);}if(fileChar[i]=='')currentLine++;if(currentLine%3==0){if(fileChar[i]=='Y'
7、
8、fileChar[i]=='y'){if(State==1){baiduCnt++;baiduY[currentLine/3]=true;}elseif(State==2){bingCnt++;bingY[currentLine/3-50]=true;//Syste
9、m.out.println(currentLine/3-50);}elseif(State==3){sogouCnt++;sogouY[currentLine/3-100]=true;}elseif(State==4){_360Cnt++;_360Y[currentLine/3-150]=true;}cntRelated++;}}}try{CaculatePR(baiduY,bingY,_360Y,sogouY,cntRelated);}catch(Exceptione){e.getMessage();}System.o
10、ut.println("cntRelated="+cntRelated);System.out.println("baiduCnt="+baiduCnt);System.out.println("bingCnt="+bingCnt);System.out.println("sohuCnt="+sogouCnt);Sy
此文档下载收益归作者所有