import java.io.*;
class ren{
String str,data;
String[] ph=new String[500];
String[] dic=new String[1000];
int[][] mk=new int[1000][500];
int[] mknumber=new int[1000];
int[] np=new int[500];
String[] word=new String[500];
int[] nword=new int[500];
double[] p=new double[10000];
int phnumber,dicnumber,wordnumber;
int s,sx,t;
double p1,point,maxp;
int tr;
public static void main(String args[]){
ren test=new ren();
}
ren(){
readfile("pp.txt");
String[] x=data.split("。");
p[0]=1;
dicnumber=0;
for(t=0;t<x.length;t++){
str=x[t];
maxp=-999;
for (tr=1;tr<11;tr++){
gen g=new gen();
g.dicnumber=dicnumber;
g.dic=dic;
g.makedata(str);
ph=g.ph;
phnumber=g.phnumber;
np=g.np;
price pr=new price();
pr.mk=mk;
pr.mknumber=mknumber;
sx=np[1];
point=p[sx];
for(s=1;s<phnumber;s++){
pr.makedata(t,np[s],np[s+1]);
p1=pr.px;
point=p1*point;
}
if(point>maxp)word=ph;
if(point>maxp)wordnumber=phnumber;
if(point>maxp)nword=np;
if(point>maxp)maxp=point;
}
for(s=1;s<wordnumber+1;s++){
if(nword[s]==0)makedic(s);
}
makep mp=new makep();
mp.wordnumber=wordnumber;
mp.dicnumber=dicnumber;
mp.word=word;
mp.nword=nword;
mp.dic=dic;
mp.p=p;
mp.makedata();
p=mp.p;
mknumber[t]=wordnumber;
for(s=1;s<wordnumber+1;s++){
if(nword[s]>0)mk[t][s]=nword[s];
if(nword[s]==0)mk[t][s]=makemk(t,s);
}
System.out.println(t);
System.out.println(maxp);
}
}
void makedic(int s){
int h;
h=0;
for(sx=1;sx<dicnumber+1;sx++){
if(word[s].equals(dic[sx]))h=100;
}
if(h<50)dicnumber=dicnumber+1;
if(h<50)dic[dicnumber]=word[s];
}
int makemk(int t,int s){
int sx,sxs;
sxs=0;
for(sx=1;sx<dicnumber+1;sx++){
if(word[s].equals(dic[sx]))sxs=sx;
}
return sxs;
}
void readfile(String file){
String st;
BufferedReader br;
data="";
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"SJIS"));
while((st = br.readLine()) != null) {
data=data+st;
}
br.close();
} catch (IOException e) {System.out.println(e);}
}
}
最終更新:2011年05月24日 03:17