import java.io.*;
class pro{
String[] data=new String[50000];
int s,sx,datanumber,wordnumber;
int[][] sdata=new int[500][10000];
int[][] xx=new int[500][10000];
int[] y=new int[500];
int xp;
double[][] x=new double[500][10000];
double[] a=new double[21];
double b;
public static void main(String args[]){
pro test=new pro();
}
pro(){
readfile("svm.txt");
for(s=1;s<datanumber+1;s++){
String[] z=data[s].split(",");
wordnumber=z.length;
for(sx=0;sx<z.length;sx++){
sdata[s][sx+1]=Integer.parseInt(z[sx]);
}
}
System.out.println(wordnumber);
System.out.println(datanumber);
for(s=1;s<datanumber+1;s++){
xx[s][1]=sdata[s][35];
xx[s][2]=sdata[s][455];
xx[s][3]=sdata[s][446];
xx[s][4]=sdata[s][197];
xx[s][5]=sdata[s][849];
xx[s][6]=sdata[s][799];
xx[s][7]=sdata[s][251];
xx[s][8]=sdata[s][127];
xx[s][9]=sdata[s][174];
xx[s][10]=sdata[s][304];
xx[s][11]=sdata[s][614];
xx[s][12]=sdata[s][667];
xx[s][13]=sdata[s][537];
xx[s][14]=sdata[s][945];
xx[s][15]=sdata[s][1035];
xx[s][16]=sdata[s][1809];
xx[s][17]=sdata[s][1689];
xx[s][18]=sdata[s][1678];
xx[s][19]=sdata[s][1630];
xx[s][20]=sdata[s][306];
}
for(s=1;s<8;s++){
y[s]=1;
}
for(s=8;s<datanumber+1;s++){
y[s]=0;
}
for(s=1;s<datanumber+1;s++){
xp=0;
for(sx=1;sx<21;sx++){
xp=xp+xx[s][sx];
}
for(sx=1;sx<21;sx++){
x[s][sx]=(double)xx[s][sx]/xp;
}
}
for(sx=1;sx<21;sx++){
a[sx]=1;
}
b=1;
s=1;
System.out.println(g(a,b,s,x));
}
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;
}
double g(double[] a,double b,int m,double[][] x){
double g1;
g1=b;
for (sx=1;sx<21;sx++){
g1=g1+a[sx]*x[m][sx];
}
return g1;
}
}
最終更新:2011年06月03日 21:57