package sen5;
import java.io.File;
import tool.*;
public class pro {
int s,datanumber;
String[] point=new String[5000];
String[] data=new String[5000];
String[] name=new String[5000];
String[] party=new String[5000];
String[] v=new String[5000];
String[] web=new String[5000];
public static void main(String[] args) {
pro t=new pro();
}
pro(){
File f=new File("data");
String[] ff=f.list();
int tr;
for(tr=0;tr<ff.length;tr++){
readfile sub3=new readfile();
sub3.makedata("data/"+ff[tr],"UTF-8");
data=sub3.data;
datanumber=sub3.datanumber;
int s1=0;
for(s=1;s<datanumber+1;s++){
int h=0;
if(data[s].indexOf("<div style=")>-1)h=h+1;
if(data[s].indexOf("第48回衆議院議員総選挙")>-1)h=h+1;
if(h==2)s1=s;
}
int s2=0;
for(s=s1+1;s<datanumber+1;s++){
int h=0;
if(data[s].indexOf("</table>")>-1)h=h+1;
if(s2==0)h=h+1;
if(h==2)s2=s;
}
String str="";
for(s=s1+1;s<s2;s++){
str=str+data[s];
}
int sx;
String[] x=str.split("</tr>");
for(s=1;s<x.length;s++){
String[] x1=x[s].split("</td>");
web[s]="";
for(sx=0;sx<x1.length;sx++){
if(sx==0)point[s]=clean_str(x1[sx]);
if(sx==1)name[s]=clean_str(x1[sx]);
if(sx==3)party[s]=clean_str(x1[sx]);
if(sx==5)v[s]=clean_str(x1[sx]);
if(sx==1)web[s]=x1[sx];
}
v[s]=""+v[s];
v[s]=v[s].replace(",","");
}
int de=x.length-1;
for(s=1;s<de+1;s++){
int p1=web[s].indexOf("/wiki/");
int p2=web[s].indexOf("\"",p1);
String sig="";
if(p1>0)sig=web[s].substring(p1,p2);
data[s]=name[s]+","+party[s]+","+point[s]+","+v[s]+","+sig;
}
writefile sub2=new writefile();
sub2.data=data;
sub2.datanumber=de;
sub2.makedata("gdata/"+ff[tr]);
}
}
String clean_str(String str){
int kk;
String sp=str;
for(kk=1;kk<15;kk++){
sp=fresh(sp);
}
return sp;
}
String fresh(String strstr){
strstr=""+strstr;
int p1=strstr.indexOf("<");
int p2=-1;
if(p1>-1)p2=strstr.indexOf(">",p1);
String k="";
if(p2>-1)k=strstr.substring(p1,p2)+">";
String strxp=strstr.replace(k,"");
return strxp;
}
}
最終更新:2017年10月27日 05:28