import java.io.*;
class den{
int[] com=new int[20];
int[] index=new int[500];
String[] data=new String[50000];
String[] author=new String[50000];
String[] credit=new String[5000];
String[] article=new String[500];
int s,sx,datanumber,creditnumber;
int authornumber,indexnumber,number;
int page,m,n,h,h1;
int p1,p2,t;
String file,bun,str,str1,str2;
public static void main(String[] args){
den test=new den();
}
den(){
str1="(";
str2=")";
readfile("c.txt");
for(s=1;s<datanumber+1;s++){
author[s]=data[s];
}
authornumber=datanumber;
makecom();
number=0;
for(m=13;m<20;m++){
for(n=1;n<com[m]+1;n++){
number=number+1;
page=m*100+n;
file="data/";
file=file+page;
file=file+".txt";
readfile(file);
sx=0;
for(s=1;s<datanumber+1;s++){
h=0;
p1=data[s].indexOf(str1);
p2=data[s].indexOf(str2);
if(p1==0)h=h+1;
if(p2>0)h=h+1;
str="";
if(h==2)str=data[s].substring(p1+1,p2);
credit[s]=str;
}
t=0;
for(s=1;s<datanumber+1;s++){
h=0;
for(sx=1;sx<authornumber+1;sx++){
h1=0;
if(credit[s].indexOf(author[sx])>-1)h1=100;
if(credit[s].indexOf("答申文")>0)h1=0;
if(credit[s].indexOf("退室")>0)h1=0;
if(credit[s].indexOf("入室")>0)h1=0;
if(credit[s].indexOf("提出資料")>0)h1=0;
if(h1>50)h=100;
}
if(h>50)t=t+1;
if(h>50)index[t]=s;
}
indexnumber=t;
for(s=1;s<indexnumber;s++){
p1=index[s];
p2=index[s+1];
bun=data[p1];
for(sx=p1+1;sx<p2;sx++){
bun=bun+data[sx];
}
article[s]=bun;
}
file="gdata/";
file=file+number;
file=file+".txt";
writefile(file);
}
}
}
void makecom(){
com[13]=35;
com[14]=42;
com[15]=30;
com[16]=35;
com[17]=31;
com[18]=31;
com[19]=15;
}
void writefile(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter(file)));
for(s=1;s<indexnumber;s++){
pw.println(article[s]);
}
System.out.println("ファイルに書きこみました。");
pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
void readfile(String file){
String str;
BufferedReader br;
s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"SJIS"));
while((str = br.readLine()) != null) {
s=s+1;
data[s]=str;
}
br.close();
} catch (IOException e) {System.out.println(e);}
datanumber=s;
}
}
最終更新:2011年07月08日 04:03