アットウィキロゴ

AUTH

import java.io.*;

class author{

int s,sx,sxs,datanumber,articlenumber;
String[] data=new String[50000];  
String[] article=new String[50000];  
String[] author=new String[50000];  
String[] dic=new String[5000];  
int[] num=new int[5000];
int[] ch=new int[5000];
int[] rank=new int[5000];
int maxn,r;
int dicnumber,h;

public static void main(String args[]){
author test=new author();
}

author(){

readfile("article.txt");

sx=0;
for(s=1;s<datanumber+1;s++){
String[] x=data[s].split(",");
if(x.length>1)sx=sx+1;
if(x.length>1)author[sx]=x[0];
if(x.length>1)article[sx]=x[1];
}

articlenumber=sx;

System.out.println(articlenumber);

dicnumber=0;
for(s=1;s<articlenumber+1;s++){
h=0;
for(sx=1;sx<dicnumber+1;sx++){
if(author[s].equals(dic[sx]))h=100;
}
if(h<50)dicnumber=dicnumber+1;
if(h<50)dic[dicnumber]=author[s];
}

System.out.println(dicnumber);


for(s=1;s<articlenumber+1;s++){
sxs=0;
for(sx=1;sx<dicnumber+1;sx++){
if(author[s].equals(dic[sx]))sxs=sx;
}
num[sxs]=num[sxs]+1;
}


for(r=1;r<1000;r++){
maxn=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;
}
ch[sx]=100;
rank[r]=sx;
}


for(r=1;r<100;r++){
sx=rank[r];
System.out.println(dic[sx]);
}

writefile("author.txt");

}

void writefile(String str){

try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter(str)));

for(s=1;s<1000;s++){                              
sx=rank[s];
pw.println(dic[sx]);              
}      

System.out.println("ファイルに書きこみました。");

pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }

}




void readfile(String file){

String str;
BufferedReader br;
int s;
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年06月12日 02:03