アットウィキロゴ

XYZ

import java.io.*;

class credit{

String file,str;
String[] data=new String[10000];  
String[] credit=new String[5000];
String[] author=new String[5000];  
String[] memo=new String[5000];  
int[] count=new int[200];
int page,h;
int s,sx,datanumber;
int n,p1,p2;
int articlenumber,authornumber;
String x1;


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

credit(){

readfile("count.txt");

for(s=1;s<177;s++){
count[s]=Integer.parseInt(data[s]);
}

for(page=1;page<50;page++){
for(n=1;n<count[page]+1;n++){

file="author/";
file=file+page;
file=file+"/";
file=file+n;
file=file+".txt";

readfile(file);

authornumber=datanumber;

if(data[1].indexOf("規格外")>-1)authornumber=0;
if(authornumber>4900)authornumber=0;

for(s=1;s<authornumber+1;s++){
author[s]=data[s];
}

file="gdata/";
file=file+page;
file=file+"/";
file=file+n;
file=file+".txt";

readfile(file);

articlenumber=datanumber;

if(data[1].indexOf("規格外")>-1)articlenumber=0;

for(s=1;s<articlenumber+1;s++){
str=data[s];
p1=str.indexOf("<B>○");
p2=str.indexOf("</B>");
if(p2>p1+4)credit[s]=str.substring(p1+4,p2);
}


for(sx=1;sx<articlenumber+1;sx++){
str=credit[sx];
for(s=1;s<authornumber+1;s++){
if(point(credit[sx],s)>50)str=author[s];
}
memo[sx]=str;
}

file="credit/";
file=file+page;
file=file+"/";
file=file+n;
file=file+".txt";

if(articlenumber>0)writefile(file);
if(articlenumber==0)kfile(file);

}
}


}

void kfile(String file){

try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter(file)));
                                              
pw.println("規格外です");                                                                  

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

}

void writefile(String file){

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

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

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

}





int point(String str,int s){
String px;
int pp;
pp=0;
px="ABCDEFGHI";
if(str.length()>2)px=str.substring(0,2);
if(author[s].indexOf(px)>-1)pp=100;
return pp;
}
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月01日 19:26