アットウィキロゴ

辞書作成

import java.io.*;

public class dic{

String[] data=new String[50000];
String[] dic=new String[50000];
String[][] memo=new String[2000][1000];
int[] number=new int[2000];
int s,sx,datanumber,dicnumber;
int wordnumber,h;
String str,file;
int tx,page;

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

dic(){        

dicnumber=0;
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++){
h=0;
for(tx=1;tx<dicnumber+1;tx++){
if(memo[s][sx].equals(dic[tx]))h=100;
}
if(h<50)dicnumber=dicnumber+1;
if(h<50)dic[dicnumber]=memo[s][sx];
}
}

}

writefile("dic.txt");

}

void writefile(String file){

int s;

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;  

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:34