import java.io.*;
public class rank{
int[] rank=new int[1000];
String[] data=new String[50000];
String[] dic=new String[50000];
String[][] memo=new String[2000][1000];
int[] number=new int[2000];
int[] num=new int[50000];
int s,sx,datanumber,dicnumber;
int wordnumber,h;
String str,file;
int tx,txs,page;
public static void main(String[] args){
rank test=new rank();
}
rank(){
readfile("dic.txt");
for(s=1;s<datanumber+1;s++){
dic[s]=data[s];
}
dicnumber=datanumber;
for(page=1;page<23;page++){
file="c/";
file=file+page;
file=file+".txt";
readfile(file);
for(s=1;s<datanumber+1;s++){
String[] x=data[s].split(">");
for(sx=0;sx<x.length;sx++){
str=x[sx];
str=str.replace("<","");
memo[s][sx+1]=str;
}
number[s]=x.length;
}
for(s=1;s<datanumber+1;s++){
for(sx=1;sx<number[s]+1;sx++){
txs=0;
for(tx=1;tx<dicnumber+1;tx++){
if(memo[s][sx].equals(dic[tx]))txs=tx;
}
num[txs]=num[txs]+1;
}
}
}
makerank();
for(s=1;s<200;s++){
sx=rank[s];
System.out.print(dic[sx]);
System.out.println(num[sx]);
}
}
void makerank(){
int r,s,sx,maxn,h;
int[] ch=new int[30000];
for(r=1;r<1000;r++){
maxn=0;
sx=0;
for(s=1;s<dicnumber+1;s++){
h=0;
if(num[s]>maxn)h=h+1;
if(ch[s]<50)h=h+1;
if(h==2)maxn=num[s];
if(h==2)sx=s;
}
rank[r]=sx;
ch[sx]=100;
}
}
void readfile(String file){
String str;
BufferedReader br;
s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"SJIS"));
while((str = br.readLine()) != null) {
s=s+1;
data[s]=str;
}
br.close();
} catch (IOException e) {System.out.println(e);}
datanumber=s;
}
}
最終更新:2011年07月12日 04:43