アットウィキロゴ

大量処理

import java.io.*;

class pro{

String data,data1,data2,px;
String[] person=new String[1000];
String[] author=new String[1000];
String[] pauthor=new String[1000];
int personnumber;
String file;
int page,h;  
int cnumber,pnumber,plong;
int s,p1,p2,sx;
int[] x=new int[500];
int[] y=new int[500];
int xmlnumber;
double maxp;

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

pro(){

for(page=5000;page<5100;page++){

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

System.out.println(file);

readfile(file);

h=100;
if(data.indexOf("○")>10)h=0;

p1=data.indexOf("<B>○");
p2=data.indexOf("</HTML>");
data2=data.substring(p1,p2);

person pr=new person();
if(h<50)pr.makedata(data);
if(h<50)personnumber=pr.personnumber;
if(h<50)person=pr.person;

xymaker(data2);

for(s=1;s<xmlnumber+1;s++){
author[s]=data2.substring(x[s]+4,y[s]);
}


for(sx=1;sx<xmlnumber+1;sx++){
maxp=0;
px="不明";
for(s=1;s<personnumber+1;s++){
if(point(s,sx)>maxp)px=person[s];
if(point(s,sx)>maxp)maxp=point(s,sx);
}
System.out.println(px);
}

}


}

double point(int s,int sx){
String name,pc;
int n,nlong,h;
String[] n1=new String[100];
name=person[s];
pc=author[sx];
nlong=name.length();
for(n=0;n<nlong;n++){
n1[n]=name.substring(n,n+1);
}

h=0;
for(n=0;n<nlong;n++){
if(pc.indexOf(n1[n])>-1)h=h+1;
}
return h;
}


void xymaker(String str){
int s,p1;
p1=str.indexOf("<B>");
s=1;
x[s]=p1;
while(p1>-1){
p1=str.indexOf("<B>",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]=str.indexOf("</B>",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年06月28日 19:13