アットウィキロゴ

AAAkjh

import java.io.*;

public class clu{

int s,sx,sxs,t,tx;
int datanumber,dicnumber,articlenumber;
String[] data=new String[50000];
String[] dic=new String[50000];
String[] word=new String[101];
int[] nword=new int[101];
int[][] num=new int[1000][30000];
double[][] rate=new double[1000][101];
int xlong;
int r1;
double m1;

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

clu(){        

readfile("lib.txt");

dicnumber=datanumber;

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

readfile("100.txt");

for(s=1;s<101;s++){
word[s]=data[s];
}

for(s=1;s<101;s++){
sxs=0;
for(sx=1;sx<dicnumber+1;sx++){
if(word[s].equals(dic[sx]))sxs=sx;
}
nword[s]=sxs;
}

readfile("data.txt");

articlenumber=datanumber;

System.out.println(articlenumber);

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



for(s=1;s<articlenumber+1;s++){  
r1=0;
for(sx=1;sx<101;sx++){
tx=nword[sx];
r1=r1+num[s][tx];
}
for(sx=1;sx<101;sx++){
tx=nword[sx];
if(r1>0)rate[s][sx]=(double)num[s][tx]/r1;
}
}


System.out.println(met(1,2));












}

double met(int t1,int t2){
int sx;
double m1,m2;
m2=0;
for(sx=1;sx<101;sx++){
m1=rate[t1][sx]-rate[t2][sx];
m2=m2+m1*m1;
}
return m2;
}

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月18日 12:53