package dic;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class pro {
int s,datanumber;
String[] data=new String[20000];
String[] name=new String[20000];
String[] namex=new String[20000];
String[] code=new String[20000];
String[] codex=new String[20000];
String[] dic_name=new String[20000];
String[] dic_code=new String[20000];
public static void main(String[] args) {
pro t=new pro();
}
pro(){
readx("dic.csv");
for(s=2;s<datanumber+1;s++){
String[] x=data[s].split(",");
dic_name[s-1]=x[0];
dic_code[s-1]=x[1];
}
int dicnumber=datanumber-1;
readx("t.csv");
for(s=2;s<datanumber+1;s++){
String[] x=data[s].split(",");
name[s]=x[1].replace(" ","");
namex[s]="";
if(x.length>2)namex[s]=x[2].replace(" ","");;
code[s]="";
codex[s]="";
}
int sx;
for(s=2;s<datanumber+1;s++){
int h=0;
for(sx=0;sx<dicnumber+1;sx++){
if(name[s].equals(dic_name[sx]))code[s]=dic_code[sx];
}
}
for(s=2;s<datanumber+1;s++){
int h=0;
for(sx=0;sx<dicnumber+1;sx++){
if(namex[s].equals(dic_name[sx]))codex[s]=dic_code[sx];
}
}
for(s=2;s<datanumber+1;s++){
if(code[s].length()<1){
bing sub4=new bing();
String c1=sub4.makedata(name[s]);
check sub5=new check();
String n1=sub5.makedata(c1);
System.out.println(name[s]+","+c1);
int h=0;
if(name[s].equals(n1))h=100;
if(h<50){
wiki sub6=new wiki();
String w1=sub6.makedata(name[s]);
wiki sub7=new wiki();
String w2=sub6.makedata(n1);
if(w1.equals(w2))h=100;
}
if(h>50)code[s]=c1;
}
}
for(s=2;s<datanumber+1;s++){
if(codex[s].length()<1){
bing sub4=new bing();
String c1=sub4.makedata(namex[s]);
check sub5=new check();
String n1=sub5.makedata(c1);
System.out.println(namex[s]+","+c1);
int h=0;
if(namex[s].equals(n1))h=100;
if(h<50){
wiki sub6=new wiki();
String w1=sub6.makedata(namex[s]);
wiki sub7=new wiki();
String w2=sub7.makedata(n1);
if(w1.equals(w2))h=100;
}
if(h>50)codex[s]=c1;
}
}
for(s=2;s<datanumber+1;s++){
System.out.println(name[s]+","+code[s]+","+namex[s]+","+codex[s]);
}
}
void readx(String file){
String str;
BufferedReader br;
int s;
s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));
while((str = br.readLine()) != null) {
s=s+1;
data[s]=str;
}
br.close();
} catch (IOException e) {System.out.println(e);}
datanumber=s;
}
}
package dic;
import tool.*;
public class bing {
int s,datanumber;
String[] data=new String[6000];
String makedata(String w2){
String word=w2+" site:oricon.co.jp/prof/";
makeutf sub6=new makeutf();
String d=sub6.makedata(word);
String urlx="https://www.bing.com/search?q=";
urlx=urlx+d;
getdata sub7=new getdata();
sub7.makedata(urlx,"UTF-8");
data=sub7.data;
datanumber=sub7.datanumber;
String ss="aria-label=\"検索結果";
String str="";
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf(ss)>-1)str=data[s];
}
String[] x=str.split(">");
String d2="http://www.oricon.co.jp/";
String pp="";
String[] ps=new String[500];
int sx=0;
for(s=0;s<x.length;s++){
int h=0;
if(x[s].indexOf(d2)>-1)h=h+1;
if(x[s].indexOf("/prof/")>-1)h=h+1;
if(h==2)sx=sx+1;
if(h==2)ps[sx]=x[s];
}
int number=sx;
for(s=1;s<number+1;s++){
int p1=ps[s].indexOf("http");
int p2=-1;
if(p1>-1)p2=ps[s].indexOf("\"",p1);
if(p2>-1)ps[s]=ps[s].substring(p1,p2);
}
String delta="";
String mm="";
for(s=1;s<number+1;s++){
ps[s]=ps[s].replace("/artist","");
int p1=ps[s].indexOf("prof/");
p1=ps[s].indexOf("/",p1);
int p2=ps[s].indexOf("/",p1+1);
if(p2>-1)mm=ps[s].substring(p1+1,p2);
int h=0;
if(delta.length()<1)h=h+1;
if(mm.length()>2)h=h+1;
if(h==2)delta=mm;
}
return delta;
} }
package dic;
import tool.getdata;
public class check {
int s,datanumber;
String[] data=new String[6000];
String makedata(String gid){
String urlx="http://www.oricon.co.jp/prof/";
urlx=urlx+gid+"/";
getdata sub7=new getdata();
sub7.makedata(urlx,"SJIS");
data=sub7.data;
datanumber=sub7.datanumber;
String de="";
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf("artist-link")>-1)de=data[s];
}
int p1=de.indexOf(">");
int p2=de.indexOf("<",p1);
if(p1>-1)de=de.substring(p1+1,p2);
return de;
}
}
package dic;
import tool.*;
public class wiki {
int s,datanumber;
String[] data=new String[6000];
String[] link=new String[600];
String makedata(String w2){
String word=w2+" wikipedia";
makeutf sub6=new makeutf();
String d=sub6.makedata(word);
String urlx="https://www.bing.com/search?q=";
urlx=urlx+d;
getdata sub7=new getdata();
sub7.makedata(urlx,"UTF-8");
data=sub7.data;
datanumber=sub7.datanumber;
String ss="aria-label=\"検索結果";
String str="";
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf(ss)>-1)str=data[s];
}
String[] x=str.split(">");
int sx=0;
for(s=0;s<x.length;s++){
if(x[s].indexOf("https://ja.wikipedia.org/wiki/")>-1)sx=sx+1;
if(x[s].indexOf("https://ja.wikipedia.org/wiki/")>-1)link[sx]=x[s];
}
for(s=1;s<sx+1;s++){
int p1=link[s].indexOf("http");
int p2=-1;
if(p1>-1)p2=link[s].indexOf("\"",p1);
if(p2>-1)link[s]=link[s].substring(p1,p2);
}
String delta="";
if(sx>0)delta=link[1];
return delta;
}}
最終更新:2016年08月31日 07:51