是否可以使用谷歌知识图api提出免费表格问题?

时间:2017-02-03 01:06:46

标签: google-api google-knowledge-graph

是否可以提出一个问题,例如“艾菲尔铁塔有多高?”使用谷歌知识图API?如果不是,使用什么是正确的api?

当我尝试这个时:

https://kgsearch.googleapis.com/v1/entities:search?query=how+tall+is+eiffel+tower&key=my_key&limit=1&indent=True

我得到并清空结果。

1 个答案:

答案 0 :(得分:1)

可以问一下,但是有一半的时间它会“回答”与你所要求的不同的东西,剩下的时间它会给你一个空洞的结果。

即使是明确的搜索通常也会返回空的或意外的结果。例如,当我搜索当前的美国总统时,它返回了关于巴拉克奥巴马的结果,当我搜索美国人口时,它并没有真正说出应该说什么( 318.9百万(2014) ):

=> #<HTTParty::Response:0x7ffc5857b938 parsed_response={"@context"=>{"@vocab"=>"http://schema.org/", "goog"=>"http://schema.googleapis.com/", "EntitySearchResult"=>"goog:EntitySearchResult", "detailedDescription"=>"goog:detailedDescription", "resultScore"=>"goog:resultScore", "kg"=>"http://g.co/kg"}, "@type"=>"ItemList", "itemListElement"=>[{"@type"=>"EntitySearchResult", "result"=>{"@id"=>"kg:/m/09c7w0", "name"=>"United States", "@type"=>["Country", "Thing", "Place", "AdministrativeArea"], "description"=>"Country", "image"=>{"contentUrl"=>"http://t1.gstatic.com/images?q=tbn:ANd9GcQKp8mjZhEK0hZroCA4srP9VA9eD8-0PcCsKSU4olhQlh6dMlxc", "url"=>"https://commons.wikimedia.org/wiki/File:USA_Flag_Map.svg", "license"=>"http://creativecommons.org/licenses/by-sa/2.5"}, "detailedDescription"=>{"articleBody"=>"The United States of America, commonly referred to as the United States or America, is a federal republic composed of 50 states, a federal district, five major self-governing territories, and various possessions. ", "url"=>"https://en.wikipedia.org/wiki/United_States", "license"=>"https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"}, "url"=>"http://www.usa.gov/"}, "resultScore"=>246.96698}, {"@type"=>"EntitySearchResult", "result"=>{"@id"=>"kg:/g/1q5jrvck9", "name"=>"Population: Us", "@type"=>["Thing"], "description"=>"Song by Frank Portman"}, "resultScore"=>20.875225}]}, @response=#<Net::HTTPOK 200 OK readbody=true>, @headers={"content-type"=>["application/json; charset=UTF-8"], "vary"=>["Origin", "X-Origin", "Referer"], "date"=>["Fri, 03 Feb 2017 20:33:38 GMT"], "server"=>["ESF"], "cache-control"=>["private"], "x-xss-protection"=>["1; mode=block"], "x-frame-options"=>["SAMEORIGIN"], "x-content-type-options"=>["nosniff"], "alt-svc"=>["quic=\":443\"; ma=2592000; v=\"35,34\""], "connection"=>["close"], "transfer-encoding"=>["chunked"]}>

无论我如何使用查询或我使用的关键字,它实际上都是无用的。我也尝试过指定我想要的&types=个结果。它很少能够恢复预期的结果;例如,当我搜索美利坚合众国时:

=> #<HTTParty::Response:0x7ffc58619f20 parsed_response={"@context"=>{"@vocab"=>"http://schema.org/", "goog"=>"http://schema.googleapis.com/", "EntitySearchResult"=>"goog:EntitySearchResult", "detailedDescription"=>"goog:detailedDescription", "resultScore"=>"goog:resultScore", "kg"=>"http://g.co/kg"}, "@type"=>"ItemList", "itemListElement"=>[{"@type"=>"EntitySearchResult", "result"=>{"@id"=>"kg:/m/09c7w0", "name"=>"United States", "@type"=>["Country", "Thing", "Place", "AdministrativeArea"], "description"=>"Country", "image"=>{"contentUrl"=>"http://t1.gstatic.com/images?q=tbn:ANd9GcQKp8mjZhEK0hZroCA4srP9VA9eD8-0PcCsKSU4olhQlh6dMlxc", "url"=>"https://commons.wikimedia.org/wiki/File:USA_Flag_Map.svg", "license"=>"http://creativecommons.org/licenses/by-sa/2.5"}, "detailedDescription"=>{"articleBody"=>"The United States of America, commonly referred to as the United States or America, is a federal republic composed of 50 states, a federal district, five major self-governing territories, and various possessions. ", "url"=>"https://en.wikipedia.org/wiki/United_States", "license"=>"https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"}, "url"=>"http://www.usa.gov/"}, "resultScore"=>4238.782227}]}, @response=#<Net::HTTPOK 200 OK readbody=true>, @headers={"content-type"=>["application/json; charset=UTF-8"], "vary"=>["Origin", "X-Origin", "Referer"], "date"=>["Fri, 03 Feb 2017 20:29:07 GMT"], "server"=>["ESF"], "cache-control"=>["private"], "x-xss-protection"=>["1; mode=block"], "x-frame-options"=>["SAMEORIGIN"], "x-content-type-options"=>["nosniff"], "alt-svc"=>["quic=\":443\"; ma=2592000; v=\"35,34\""], "connection"=>["close"], "transfer-encoding"=>["chunked"]}>

我建议不要像以前那样浪费你的时间。另请注意,Custom Search API不包含知识图表的结果,并且“非自定义”搜索API长期以来一直是deprecated