package check;
import tool.*;
public class pro {
double p1;
String[] dic=new String[5000];
String[] code=new String[5000];
int s,dicnumber;
public static void main(String[] args) {
pro test=new pro();
}
pro(){
for(s=1;s<22;s++){
code[s]=""+(s+8);
}
readfile sub=new readfile();
sub.makedata("e.txt", "UTF-8");
dic=sub.data;
dicnumber=sub.datanumber;
double maxv;
String name,bc;
name="";
bc="";
maxv=-999;
for(s=1;s<dicnumber+1;s++){
check sub2=new check();
p1=sub2.makedata("非鉄金属", dic[s]);
if(p1>maxv)name=dic[s];
if(p1>maxv)bc=code[s];
if(p1>maxv)maxv=p1;
}
System.out.println(name+","+bc);
}
}
package check;
public class check {
String[] dic=new String[500];
String[] word=new String[500];
double[][] x=new double[500][500];
double[][] v=new double[500][500];
int dicnumber,wordnumber;
int s,sx,tx;
double p;
double makedata(String w1,String d1){
p=0.9;
makedic(d1);
makeword(w1);
for(s=1;s<wordnumber+1;s++){
for(sx=1;sx<dicnumber+1;sx++){
x[s][sx]=Math.log(1-p);
if(word[s].equals(dic[sx]))x[s][sx]=Math.log(p);
}
}
for(sx=1;sx<dicnumber+1;sx++){
v[1][sx]=x[1][sx];
}
double u1,v1,maxv;
for(s=1;s<wordnumber+1;s++){
for(sx=1;sx<dicnumber+1;sx++){
u1=x[s][sx];
maxv=-999;
for(tx=1;tx<dicnumber+1;tx++){
v1=u1+v[s-1][tx];
if(tx>sx)v1=-999;
if(v1>maxv)maxv=v1;
}
v[s][sx]=maxv;
}
}
maxv=-999;
for(sx=1;sx<dicnumber+1;sx++){
if(v[wordnumber][sx]>maxv)maxv=v[wordnumber][sx];
}
return maxv;
}
void makeword(String str){
wordnumber=str.length();
int s;
for(s=1;s<wordnumber+1;s++){
word[s]=str.substring(s-1,s);
}
}
void makedic(String str){
dicnumber=str.length();
int s;
for(s=1;s<dicnumber+1;s++){
dic[s]=str.substring(s-1,s);
}
}
}
食料品製造業
飲料・たばこ・飼料製造業
繊維工業
木材・木製品製造業
家具・装備品製造業
パルプ・紙・紙加工品製造業
印刷・同関連業
化学工業
石油製品・石炭製品製造業
プラスチック製品製造業
ゴム製品製造業
なめし革・同製品・毛皮製造業
窯業・土石製品製造業
鉄鋼業
非鉄金属製造業
金属製品製造業
はん用機械器具製造業
生産用機械器具製造業
業務用機械器具製造業
電子部品・デバイス・電子回路製造業
電気機械器具製造業
情報通信機械器具製造業
輸送用機械器具製造業
その他の製造業
最終更新:2014年03月31日 20:19