アットウィキロゴ

AAJJ

import java.io.*;

public class pro{

int s,sx,datanumber,articlenumber;
String[] data=new String[50000];
String[] dic=new String[50000];  
int[][] nword=new int[5000][5000];
int[] wordnumber=new int[5000];
int[][] num=new int[1000][30000];
int[] rank=new int[2000];
int[] ch=new int[50000];
int p;
int xlong,h,dicnumber;
String file;
int n,sxs,maxn;

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

pro(){        

readfile("lib.txt");

for(s=1;s<datanumber+1;s++){
dic[s]=data[s];
}

dicnumber=datanumber;

for(n=1;n<900;n++){

file="ndata/";
file=file+n;
file=file+".txt";

readfile(file);

articlenumber=datanumber;

for(s=1;s<datanumber+1;s++){
String[] x=data[s].split(",");
xlong=x.length;
wordnumber[s]=xlong;
for(sx=1;sx<xlong+1;sx++){
nword[s][sx]=Integer.parseInt(x[sx-1]);
}
}


for(s=1;s<datanumber+1;s++){
xlong=wordnumber[s];
for(sx=1;sx<xlong+1;sx++){
p=nword[s][sx];
if(p>0)num[n][p]=num[n][p]+1;
}
}

}


writefile();


}


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;

}

void writefile(){

try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter("data.txt")));


for(s=1;s<901;s++){
for(sx=1;sx<dicnumber;sx++){                                              
pw.print(num[s][sx]);                              
pw.print(",");                              
}
sx=dicnumber;
pw.println(num[s][sx]);                              
}

System.out.println("ファイルに書きこみました。");
pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }

}







}
最終更新:2011年06月14日 03:54