import java.io.*;
public class lib{
int s,sx,tx,datanumber,articlenumber;
String[] data=new String[50000];
String[] dic=new String[50000];
String[][] word=new String[5000][5000];
int[] wordnumber=new int[5000];
int xlong,h,dicnumber;
String file;
int n;
public static void main(String[] args){
lib test=new lib();
}
lib(){
dicnumber=0;
for(n=800;n<901;n++){
readfile("lib.txt");
for(s=1;s<datanumber+1;s++){
dic[s]=data[s];
}
dicnumber=datanumber;
file="data/";
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++){
word[s][sx]=x[sx-1];
}
}
for(s=1;s<datanumber+1;s++){
xlong=wordnumber[s];
for(sx=1;sx<xlong+1;sx++){
h=0;
for(tx=1;tx<dicnumber+1;tx++){
if(word[s][sx].equals(dic[tx]))h=100;
}
if(h<50)dicnumber=dicnumber+1;
if(h<50)dic[dicnumber]=word[s][sx];
}
}
System.out.println(dicnumber);
writefile("lib.txt");
}
}
void writefile(String file){
try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter(file)));
for(s=1;s<dicnumber+1;s++){
pw.println(dic[s]);
}
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月13日 06:02