我们正在尝试将 Google 的知识图与我们的一个应用程序集成,我们发现知识图对于热门结果非常有用,但对未定义其图的鲜为人知的查询的结果感到好奇。
1 回答
1
根据我最近的搜索/我对它的简短经验,大多数时候谷歌的知识图 API 会返回空结果,即使一个简单的谷歌搜索与完全相同的查询会给我我正在寻找的结果。这就是我所说的“空结果”(当我搜索 2014 Toyota Camry SE 轮胎尺寸时),例如:
[16] pry(main)> response = HTTParty.get("https://kgsearch.googleapis.com/v1/entities:search?query=2014 Toyota Camry SE tire size&key=#{API_KEY}")
=> {"@context"=>
{"@vocab"=>"http://schema.org/",
"goog"=>"http://schema.googleapis.com/",
"EntitySearchResult"=>"goog:EntitySearchResult",
"detailedDescription"=>"goog:detailedDescription",
"kg"=>"http://g.co/kg"},
"@type"=>"ItemList",
"itemListElement"=>[]}
其他时候它返回不准确的结果(不是我想要的)。在以下示例中,我正在搜索有关 2014 Toyota Camry 的信息,但所有结果都显示为好像我正在搜索与该公司相关的信息
[4] pry(main)> response = HTTParty.get("https://kgsearch.googleapis.com/v1/entities:search?query=2014 toyota camry&key=#{API_KEY}")
=> {"@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/02qtntf",
"name"=>"Toyota Kirloskar Motor",
"@type"=>["Corporation", "Thing", "Organization"],
"description"=>"Automotive industry company",
"detailedDescription"=>
{"articleBody"=>
"Toyota Kirloskar Motor Pvt Ltd is a subsidiary of Toyota Motor Corporation of Japan, for the manufacture and sales of Toyota cars in India. It is currently the 4th largest car maker in India after Maruti Suzuki, Hyundai, and Mahindra.\n",
"url"=>"https://en.wikipedia.org/wiki/Toyota_Kirloskar_Motor",
"license"=>"https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"},
"url"=>"http://www.toyotabharat.com"}
...
我还没有得到我正在寻找的结果——即使我指定了类型(即。&types=Car
)。
我不知道为什么会这样,但确实如此。
于 2017-02-03T02:14:13.197 回答