Freebase 查找替代公司名称
Freebase to find alternative company names
我正在尝试使用 Freebase 查找指定公司的所有备选名称。我目前有以下代码,当您指定您希望名称使用的语言时,它可以工作。我希望它 return 所有别名,无论语言如何。但是,如果我不指定语言,则不会 returned 任何结果。此外,如果我将查询中的所有语言作为一个长列表包含在内,它 return 的结果是错误的公司。当我在下面的代码中执行此操作时,它 returned 了美国银行的结果。有没有办法指定所有语言?该代码的主要目的是查找公司的常用首字母缩略词,尽管 select 全名也很有用。
HttpTransport httpTransport = new NetHttpTransport();
HttpRequestFactory requestFactory = httpTransport.createRequestFactory();
JSONParser parser = new JSONParser();
GenericUrl url = new GenericUrl("https://www.googleapis.com/freebase/v1/search");
url.put("query", "Royal Bank of Scotland");
url.put("filter", "(all type:/organization/organization )");
url.put("limit", "1");
url.put("output", "( /common/topic/alias )");
url.put("lang", "cs");//Specify Laungauges
url.put("key", properties.get("API_KEY"));
HttpRequest request = requestFactory.buildGetRequest(url);
HttpResponse httpResponse = request.execute();
JSONObject response = (JSONObject)parser.parse(httpResponse.parseAsString());
JSONArray results = (JSONArray)response.get("result");
System.out.println(results);
lang
参数采用逗号分隔的语言列表。如果你真的想要 all,你可以只使用当前的整个列表:
"en,es,fr,de,it,pt,zh,ja,ko,ru,sv,fi,da,nl,el,ro,tr,hu,th,pl,cs,id,bg,uk,ca,eu,no,sl,sk,hr,sr,ar,hi,vi,fa,ga,iw,lv,lt,gl,is,hy,lo,km,sq,fil,zxx"
来自 https://www.googleapis.com/freebase/v1/search?help=langs&indent=true as documented on https://developers.google.com/freebase/v1/search-cookbook#language-constraints
这个查询对我有用:
https://www.googleapis.com/freebase/v1/search?query="Royal%20Bank%20of%20Scotland"&filter=(all%20type:/organization/organization%20)&limit=1&output=(/common/topic/alias%20)&lang=en,es,fr ,de,it,pt,zh,ja,ko,ru,sv,fi,da,nl,el,ro,tr,hu,th,pl,cs,id,bg,uk,ca,eu,no,sl ,sk,hr,sr,ar,hi,vi,fa,ga,iw,lv,lt,gl,is,hy,lo,km,sq,fil,zxx
我正在尝试使用 Freebase 查找指定公司的所有备选名称。我目前有以下代码,当您指定您希望名称使用的语言时,它可以工作。我希望它 return 所有别名,无论语言如何。但是,如果我不指定语言,则不会 returned 任何结果。此外,如果我将查询中的所有语言作为一个长列表包含在内,它 return 的结果是错误的公司。当我在下面的代码中执行此操作时,它 returned 了美国银行的结果。有没有办法指定所有语言?该代码的主要目的是查找公司的常用首字母缩略词,尽管 select 全名也很有用。
HttpTransport httpTransport = new NetHttpTransport();
HttpRequestFactory requestFactory = httpTransport.createRequestFactory();
JSONParser parser = new JSONParser();
GenericUrl url = new GenericUrl("https://www.googleapis.com/freebase/v1/search");
url.put("query", "Royal Bank of Scotland");
url.put("filter", "(all type:/organization/organization )");
url.put("limit", "1");
url.put("output", "( /common/topic/alias )");
url.put("lang", "cs");//Specify Laungauges
url.put("key", properties.get("API_KEY"));
HttpRequest request = requestFactory.buildGetRequest(url);
HttpResponse httpResponse = request.execute();
JSONObject response = (JSONObject)parser.parse(httpResponse.parseAsString());
JSONArray results = (JSONArray)response.get("result");
System.out.println(results);
lang
参数采用逗号分隔的语言列表。如果你真的想要 all,你可以只使用当前的整个列表:
"en,es,fr,de,it,pt,zh,ja,ko,ru,sv,fi,da,nl,el,ro,tr,hu,th,pl,cs,id,bg,uk,ca,eu,no,sl,sk,hr,sr,ar,hi,vi,fa,ga,iw,lv,lt,gl,is,hy,lo,km,sq,fil,zxx"
来自 https://www.googleapis.com/freebase/v1/search?help=langs&indent=true as documented on https://developers.google.com/freebase/v1/search-cookbook#language-constraints
这个查询对我有用:
https://www.googleapis.com/freebase/v1/search?query="Royal%20Bank%20of%20Scotland"&filter=(all%20type:/organization/organization%20)&limit=1&output=(/common/topic/alias%20)&lang=en,es,fr ,de,it,pt,zh,ja,ko,ru,sv,fi,da,nl,el,ro,tr,hu,th,pl,cs,id,bg,uk,ca,eu,no,sl ,sk,hr,sr,ar,hi,vi,fa,ga,iw,lv,lt,gl,is,hy,lo,km,sq,fil,zxx