class pro{
String str;
int dicnumber,wordnumber;
int strlong,sx;
String ph;
String[] dic=new String[100];
String[] word=new String[100];
double[] p=new double[100];
double[] v=new double[100];
int[] goton=new int[100];
double p1,v1,maxv;
int t,tx,txs;
public static void main(String args[]){
pro test=new pro();
}
pro(){
dicnumber=0;
p[0]=0.01;
str="どんぶりは犬の餌です";
strlong=str.length();
ph=str.substring(0,1);
p1=p[0];
for(sx=1;sx<dicnumber+1;sx++){
if(ph.equals(dic[sx]))p1=p[sx];
}
v[0]=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=-1;
maxv=p1;
for(tx=0;tx<t;tx++){
ph=str.substring(tx+1,t+1);
p1=p[0];
for(sx=1;sx<dicnumber+1;sx++){
if(ph.equals(dic[sx]))p1=p[sx];
}
v1=p1*v[tx];
if(v1>maxv)txs=tx;
if(v1>maxv)maxv=v1;
}
goton[t]=txs;
v[t]=maxv;
}
t=strlong-1;
wordnumber=0;
while(t>0){
wordnumber=wordnumber+1;
tx=goton[t];
word[wordnumber]=str.substring(tx+1,t+1);
t=tx;
System.out.println(word[wordnumber]);
}
}
}
最終更新:2011年05月27日 04:11