アットウィキロゴ

ぺrそnXX

import java.io.*;

class person{

String data,file,datax,datay,dataz;
int s,page,p1,p2;
int datalong,xlong,ylong;
int h;
int xmlnumber;
String[] expert=new String[1000];
String[] rep=new String[1000];
int elong,rlong;

public static void main(String [] args) {
        person test=new person();
            }
person(){

for(page=6000;page<7000;page++){

file="data/";
file=file+page;
file=file+".txt";

readfile(file);

p1=data.indexOf("<B>○");

datax="";
if(p1>10)datax=data.substring(0,p1);

datalong=datax.length();

p1=datax.indexOf("出席委員");
p2=datax.indexOf("委員外の出席者");

h=0;
if(p1>0)h=h+1;
if(p2>0)h=h+1;
if(h==2)datay=datax.substring(p1+4,p2);
if(h==2)makerep(datay);

if(h==2)dataz=datax.substring(p2+7,datalong);
if(h==2)makeexp(dataz);

if(h<2)elong=0;
if(h<2)rlong=0;

file="person/";
file=file+page;
file=file+".txt";

writefile(file);

}

}

void writefile(String file){

try{

PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter(file)));

for(s=1;s<rlong+1;s++){                                                
pw.println(rep[s]);                                                              
}

for(s=1;s<elong+1;s++){                                                
pw.println(expert[s]);                                                              
}

System.out.println("ファイルに書きこみました。");
pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }

}

void makeexp(String dataz){
int s,sx,ylong,h,j;
String[] y=dataz.split("君");
ylong=y.length;
for(s=0;s<ylong-1;s++){
y[s]=y[s].replace(" ","△");
y[s]=y[s].replace("<BR>","△");
y[s]=y[s].replace("△","");
y[s]=y[s].replace("証人","");
}

sx=0;
for(s=0;s<ylong-1;s++){
h=100;
if(y[s].length()>30)h=0;
if(y[s].indexOf("辞任")>-1)h=0;
if(y[s].indexOf("選任")>-1)h=0;
if(y[s].indexOf("法案")>-1)h=0;
if(y[s].indexOf("請願")>-1)h=0;
if(y[s].indexOf("紹介")>-1)h=0;
if(y[s].indexOf("及び")>-1)h=0;
if(y[s].indexOf("補欠")>-1)h=0;
if(y[s].indexOf("、")>-1)h=0;
if(y[s].indexOf("当選")>-1)h=0;
j=0;
if(y[s].indexOf("月")>-1)j=j+1;
if(y[s].indexOf("日")>-1)j=j+1;
if(j==2)h=0;
if(h>50)sx=sx+1;
if(h>50)expert[sx]=y[s];
}
elong=sx;

}

void makerep(String datay){
int s,xlong;
String[] x=datay.split("君");
xlong=x.length;
for(s=0;s<xlong-1;s++){
x[s]=x[s].replace(" ","△");
x[s]=x[s].replace("委員長","△");
x[s]=x[s].replace("理事","△");
x[s]=x[s].replace("代理","△");
x[s]=x[s].replace("<BR>","△");
x[s]=x[s].replace("△","");
rep[s+1]=x[s];
}
rlong=xlong-1;

}

void readfile(String file){

String str;
BufferedReader br;  

data="";

try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"SJIS"));  
while((str = br.readLine()) != null) {  
data=data+str;  
}
br.close();
} catch (IOException e) {System.out.println(e);}  

}


}
最終更新:2011年06月29日 19:07