【发布时间】:2014-10-26 20:51:38
【问题描述】:
我正在尝试从搜索结果中获取值得注意的类型,例如,当我搜索“氦”时,我可以将“氦(化学元素)”和“氦(艺术家)”显示为两个选项在搜索返回多个具有相同显示名称的事物时进行选择。
现在,我可以像这样获得原始类型:
service_url = 'https://www.googleapis.com/freebase/v1/search'
params = {
'query': query,
'key': FREEBASE_KEY,
'output': '(topic)'
}
url = service_url + '?' + urllib.urlencode(params)
for result in response['result']:
print result['output']['type']['/type/object/type'][0]['name']
但这经常给我一种不是我真正想要的类型,或者仍然很模棱两可/奇怪的东西。所以我想获得 Notable Type 或 Notable For 而不仅仅是原始类型。
因此,当我在'output' 参数中将type 替换为notable_type 或/common/notable_for/display_name 或/common/topic/notable_for/ 时,我收到一个错误,因为我的搜索没有结果。
那么,我怎样才能使用输出获得 Notable Type?
非常感谢。
【问题讨论】: