アットウィキロゴ

nekonoi

class makeword{

String[] dic=new String[100];
double[] p=new double[100];  
double[] pr=new double[101];  
double[] v=new double[100];
String[] word=new String[100];
String[] phx=new String[100];
int[] gototx=new int[100];
int strlong;
String ph;
int dicnumber,wordnumber,phnumber;
int t,tx,txs,sx;
double p1,v1,maxv;

void makedata(String str){

makep(0.5);

strlong=str.length();
ph=str.substring(0,1);
phnumber=ph.length();
p1=p[0];
for(sx=1;sx<dicnumber+1;sx++){
if(ph.equals(dic[sx]))p1=p[sx];
}
v[0]=pr[phnumber]*p1;

for(t=1;t<strlong;t++){
ph=str.substring(0,t+1);
p1=p[0];
for(sx=1;sx<dicnumber+1;sx++){
if(ph.equals(dic[sx]))p1=p[sx];
}
txs=0;
maxv=p1;
for(tx=0;tx<t;tx++){
ph=str.substring(tx+1,t+1);
phnumber=ph.length();
p1=p[0];
for(sx=1;sx<dicnumber+1;sx++){
if(ph.equals(dic[sx]))p1=p[sx];
}
v1=pr[phnumber]*p1*v[tx];
if(v1>maxv)txs=tx;
if(v1>maxv)maxv=v1;
}
gototx[t]=txs;
v[t]=maxv;
}

sx=0;

t=strlong-1;
while(t>0){
tx=gototx[t];
ph=str.substring(tx+1,t+1);
t=tx;
sx=sx+1;
phx[sx]=ph;
wordnumber=wordnumber+1;
}
sx=sx+1;
phx[sx]=str.substring(0,t+1);

wordnumber=sx;

for(sx=1;sx<wordnumber+1;sx++){
word[sx]=phx[wordnumber+1-sx];
}

}

void makep(double pp){
double c1;
int k;
c1=0;
for(k=1;k<101;k++){
c1=c1+Math.pow(1-pp,k)*pp;
}

for(k=1;k<101;k++){
pr[k]=Math.pow(1-pp,k)*pp/c1;
}

}



}
最終更新:2011年05月27日 10:55