アットウィキロゴ

データ処理BB

import java.io.*;

class movie{

String file;  
String data,str,str1,str2;
int s,page,ylong;
int p1,p2,s1,s2,xmlnumber;
int[] x=new int[5000];
int[] y=new int[5000];
String[] credit=new String[5000];
String[] word=new String[5000];
String article;
String point;
String title;
String author;

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

movie(){

for(page=1;page<3000;page++){

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

readfile(file);

xymaker(data);


for(s=1;s<xmlnumber+1;s++){
if(y[s]>x[s])credit[s]=data.substring(x[s]+1,y[s]);
}

for(s=1;s<xmlnumber;s++){
word[s]="不明";
if(x[s+1]>y[s])word[s]=data.substring(y[s]+1,x[s+1]);
}

str1="google_ad_section_start";
str2="google_ad_section_end";

for(s=1;s<xmlnumber+1;s++){
if(credit[s].indexOf(str1)>-1)s1=s;
}

for(s=1;s<xmlnumber+1;s++){
if(credit[s].indexOf(str2)>-1)s2=s;
}

str="";
for(s=s1;s<s2;s++){
str=str+word[s];
}
article=str;


for(s=1;s<xmlnumber+1;s++){
if(credit[s].indexOf("点")>0)str=credit[s];
}

String[] y=str.split("=");
ylong=y.length;

str1=y[ylong-1];
p1=str1.indexOf("点");
if(p1>1)point=str1.substring(1,p1);
if(p1<2)point="不明";

s1=0;
for(s=1;s<xmlnumber+1;s++){
if(credit[s].indexOf("v:name")>0)s1=s;
}

if(s1>0)str=credit[s1];
if(s1==0)str="不明";

p1=str.indexOf("title=");
p2=str.indexOf("class",p1);

str1="不明";
if(p2>p1)str1=str.substring(p1+7,p2-2);

title=str1;

for(s=1;s<xmlnumber;s++){
if(word[s].indexOf("by")>0)str=word[s+2];
}

if(str==null)str="不明";
if(str.length()<1)str="不明";

author=str;

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

writefile(file);

}

}

void writefile(String file){

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

pw.println(author);
pw.println(title);
pw.println(point);
pw.println(article);


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


}




void xymaker(String data){
int p1;
int s;
s=1;
p1=data.indexOf("<");
x[1]=p1;
while(p1>-1){
p1=data.indexOf("<",p1+1);
if(p1>-1)s=s+1;
if(p1>-1)x[s]=p1;
}
xmlnumber=s;
for(s=1;s<xmlnumber+1;s++){
y[s]=data.indexOf(">",x[s]);
}

}

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年07月09日 02:56