从 Freebase API 读取时如何启用扩展 MQL
Freebase 包含大量文档,但缺少一些适用于许多场景的工作代码的具体示例。
其中之一是如何使用他们的 eMQL 服务来实现(在 Python 中,使用 Python Freebase 库)查询。这是他们的 MQL 服务的扩展版本。文档指出您需要“将信封参数设置为extend=true”,但我无法弄清楚如何实际做到这一点(使语法正确)。
这是我尝试使用的服务的文档:http://www.freebase。 com/docs/mql_extensions/common#service
这是我尝试使用扩展服务工作的代码示例:
query = {
"extended": True,
"query": [{
"id": "/en/settlers_of_catan",
"/common/topic/weblink": [{
"description": "Wikipedia",
"url": None
}]
}]
}
result = freebase.sandbox.mqlread(query)
此操作失败,并出现错误“类型/类型/对象没有扩展属性” 。我相信这告诉我,我实际上并没有设置扩展属性,而是试图在错误的地方进行设置。
Freebase contains a fair amount of documentation but lacks some specific examples of working code for many scenarios.
One of them is how to implement (in Python, using the Python Freebase library) a query using their eMQL service. Which is an extended version of their MQL service. The documentation states that you need to "set the envelope parameter to extended=true", but I cannot figure out how to actually do that (get the syntax right).
Here is the doc on the service I am trying to use: http://www.freebase.com/docs/mql_extensions/common#service
Here is an example of the code I am trying to get working using the extended service:
query = {
"extended": True,
"query": [{
"id": "/en/settlers_of_catan",
"/common/topic/weblink": [{
"description": "Wikipedia",
"url": None
}]
}]
}
result = freebase.sandbox.mqlread(query)
This fails, with the error, "Type /type/object does not have property extended". Which I believe is telling me I am not actually setting the extended property and am trying to do it in the wrong place.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案很简单 - 将信封设置(在本例中为“extended=true”)传递给 mqlread 函数。
当然请注意 True 中 T 的大写。
And the answer is simple - pass the envelope setting (in this case 'extended=true' to the mqlread function.
Of course note the capitalization of T in True.