import java.io.*;
class word{
String[] data=new String[50000];
String[] dic=new String[50000];
String[][] word=new String[500][10000];
String[] mini=new String[200];
int[][] nword=new int[500][10000];
int[] mn=new int[200];
int[][] num=new int[300][300];
int[] rank=new int[1000];
String[] xml=new String[20000];
String str,file;
int[] wordnumber=new int[500];
int s,sx,datanumber,xmlnumber;
int dicnumber,page,dx,dxs,tx,txs,sxs;
public static void main(String[] args){
word test=new word();
}
word(){
readfile("word.txt");
for(s=1;s<101;s++){
mini[s]=data[s];
}
readfile("dic.txt");
dicnumber=datanumber;
for(s=1;s<dicnumber+1;s++){
dic[s]=data[s];
}
for(s=1;s<101;s++){
str=mini[s];
sxs=0;
for(sx=1;sx<dicnumber+1;sx++){
if(mini[s].equals(dic[sx]))sxs=sx;
}
mn[s]=sxs;
}
for(page=1;page<220;page++){
file="nword/";
file=file+page;
file=file+".txt";
readfile(file);
for(s=1;s<datanumber+1;s++){
str=data[s];
xymaker(str);
for(sx=1;sx<xmlnumber+1;sx++){
nword[s][sx]=Integer.parseInt(xml[sx]);
}
wordnumber[s]=xmlnumber;
}
for(s=1;s<datanumber+1;s++){
for(sx=1;sx<wordnumber[s]+1;sx++){
dx=nword[s][sx];
txs=0;
for(tx=1;tx<101;tx++){
if(dx==mn[tx])txs=tx;
}
num[page][txs]=num[page][txs]+1;
}
}
}
writefile();
}
void writefile(){
int s,sx;
try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter("data.txt")));
for(s=1;s<220;s++){
for(sx=1;sx<100;sx++){
pw.print("<");
pw.print(num[s][sx]);
pw.print(">");
}
pw.print("<");
pw.print(num[s][100]);
pw.println(">");
}
System.out.println("ファイルに書きこみました。");
pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
void xymaker(String str){
int sx,p1;
int[] x=new int[10000];
int[] y=new int[10000];
sx=1;
p1=str.indexOf("<");
x[1]=p1;
while(p1>-1){
p1=str.indexOf("<",p1+1);
if(p1>0)sx=sx+1;
if(p1>0)x[sx]=p1;
}
xmlnumber=sx;
for(sx=1;sx<xmlnumber+1;sx++){
y[sx]=str.indexOf(">",x[sx]);
}
for(sx=1;sx<xmlnumber+1;sx++){
xml[sx]=str.substring(x[sx]+1,y[sx]);
}
}
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月04日 19:52