import java.io.*;
class ar{
int n1,n2,nx,h;
int s,sx,tx,datanumber;
String[] data=new String[50000];
String[] article=new String[50000];
String[] author=new String[50000];
String[] zarticle=new String[50000];
String[] zauthor=new String[50000];
int[] credit=new int[50000];
int no,p1,p2,p3,articlenumber;
String file,str,str1,str2;
int s1,s2;
public static void main(String args[]){
ar test=new ar();
}
ar(){
str1="(";
str2=")";
tx=0;
for(n1=13;n1<20;n1++){
nx=makenum(n1);
for(n2=1;n2<nx+1;n2++){
no=100*n1+n2;
file="data/";
file=file+no;
file=file+".txt";
readfile(file);
sx=0;
for(s=1;s<datanumber+1;s++){
p1=data[s].indexOf(str1);
p2=data[s].indexOf(str2,p1);
h=0;
if(p1>-1)h=h+1;
if(p2>-1)h=h+1;
if(h==2)sx=sx+1;
if(h==2)author[sx]=data[s].substring(p1+1,p2);
if(h==2)credit[sx]=s;
}
articlenumber=sx;
for(s=1;s<articlenumber;s++){
s1=credit[s];
s2=credit[s+1];
str=data[s1];
p2=str.indexOf(str2);
p1=str.length();
if(p1>p2)str=str.substring(p2+1,p1);
for(sx=s1+1;sx<s2;sx++){
str=str+data[sx];
}
article[s]=str;
}
for(s=1;s<articlenumber;s++){
tx=tx+1;
zarticle[tx]=article[s];
zauthor[tx]=author[s];
}
}
}
articlenumber=tx;
writefile("article.txt");
}
int makenum(int year){
int mk;
mk=35;
if(year==13)mk=35;
if(year==14)mk=42;
if(year==15)mk=30;
if(year==16)mk=35;
if(year==17)mk=31;
if(year==18)mk=31;
if(year==19)mk=10;
return mk;
}
void writefile(String str){
try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter(str)));
for(s=1;s<articlenumber+1;s++){
pw.print(zauthor[s]);
pw.print(",");
pw.println(zarticle[s]);
}
System.out.println("ファイルに書きこみました。");
pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
void readfile(String file){
String str;
BufferedReader br;
int s;
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年06月09日 03:15