import java.io.*;
class pro{
String[] data=new String[50000];
int s,sx,sxs,datanumber,dicnumber;
String[] word=new String[50000];
String[] dic=new String[50000];
int[] num=new int[50000];
int tr,m,n;
String str;
public static void main(String args[]){
pro test=new pro();
}
pro(){
dicnumber=0;
for(m=13;m<20;m++){
for(tr=1;tr<makenum(m)+1;tr++){
n=m*100;
n=n+tr;
str="gdata/";
str=str+n;
str=str+".txt";
readfile(str);
for(s=1;s<datanumber+1;s++){
String[] x=data[s].split(",");
if(x.length>2)word[s]=x[2];
}
for(s=1;s<datanumber+1;s++){
sxs=0;
for(sx=1;sx<dicnumber+1;sx++){
if(word[s].equals(dic[sx]))sxs=sx;
}
if(sxs==0)dicnumber=dicnumber+1;
if(sxs==0)dic[dicnumber]=word[s];
if(sxs==0)num[dicnumber]=1;
if(sxs>0)num[sxs]=num[sxs]+1;
}
System.out.println(dicnumber);
if(dicnumber>10000)diet();
}
}
writefile();
}
int makenum(int year){
int mk;
mk=35;
if(year==13)mk=35;
if(year==14)mk=42;
if(year==15)mk=30;
if(year==16)mk=35;
if(year==17)mk=31;
if(year==18)mk=31;
if(year==19)mk=10;
return mk;
}
void writefile(){
try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter("dic.txt")));
for(s=1;s<dicnumber+1;s++){
pw.print(s);
pw.print(",");
pw.println(dic[s]);
}
System.out.println("ファイルに書きこみました。");
pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
void diet(){
int[] ch=new int[50000];
int[] newnum=new int[50000];
String[] newdic=new String[50000];
int newdicnumber;
sx=0;
for(s=1;s<dicnumber+1;s++){
ch[s]=0;
if(num[s]>5)sx=sx+1;
if(num[s]>5)ch[s]=sx;
}
newdicnumber=sx;
for(s=1;s<dicnumber+1;s++){
sx=ch[s];
if(sx>0)newdic[sx]=dic[s];
if(sx>0)newnum[sx]=num[s];
}
dicnumber=newdicnumber;
dic=newdic;
num=newnum;
}
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月03日 14:58