Freebase:格式化搜索结果以列出未知类型对象的所有属性
我正在尝试编写一个 MQL 查询来格式化 freebase 中的搜索结果(搜索 API 中的“输出”参数)。我本质上想找到给定搜索结果的所有属性的(简单)值(事先不知道结果类型)。我所说的“简单”是指,如果值是复杂对象,则仅使用默认属性。
例如,如果我搜索“Yo La Tengo”,这会将我带到“/en/yo_la_tengo”的结果,我希望能够获得该团体的成员(我只需要姓名,而不是乐器或开始日期)、专辑(再次,只是名称),贡献的电影(再次,只是名称)等。
鉴于我对类型一无所知,是否有一种简单的方法可以通过搜索输出查询来执行此操作?我想我可以使用某种反射魔法,并且我尝试过使用“/type/reflect”进行修改,但我没有得到任何结果。我是 MQL 的新手(尽管我有丰富的 SQL 经验),所以这有点令人畏惧。有什么想法吗?
编辑:所以澄清一下,我认为我看到的问题是由于“表演”(电影中的演员)或“婚姻”等中介类型造成的。例如,关于 Yo La Tengo,我可以看到我感兴趣的大部分(全部?)信息,但是关于 [The Muppet] 的类似查询电影]( freebase.com/api/service/search?limit=1&mql_output=%5B%7B%22%2Ftype%2Freflect%2Fany_reverse%22%3A%5B%7B%7D%5D%2C%22%2Ftype% 2Freflect%2Fany_master%22%3A%5B%7B%7D%5D%2C%22%2Ftype%2Freflect%2Fany_value%22%3A%5B%7B%7D%5D%7D%5D&query=The%20Muppet%20Movie - - 抱歉,SO 认为我是垃圾邮件发送者,所以我不能将其作为链接),我根本没有看到 Frank Oz 的参考(可能是因为他的表现被参考了)。有没有一种通用的方法可以让我“遵循”中介类型来获取它们的所有属性?例如,是否有一个单一的输出 MQL 可以让我获得表演中的演员(当链接到电影搜索结果时)并给出婚姻中的配偶(当与个人链接时) ?
I'm trying to write a MQL query to format a search result in freebase (the "output" parameter in the search API). I essentially want to find the (simple) values of all the properties of a given search result (without knowing anything about the types of the result a priori). By "simple", I mean only the default properties if the values are complex objects.
E.g., if I search for "Yo La Tengo" and this takes me to the result for "/en/yo_la_tengo", I want to be able to get the group's members (I just need names, not instruments or dates started), albums (again, just names), films contributed to (again, just names), etc.
Is there a simple way to do this with a search output query, given that I know nothing about the types? I imagine there's some sort of reflection magic I can use, and I've tried mucking about with "/type/reflect", but I'm not getting anywhere. I'm brand-new to MQL (though I have extensive SQL experience), so this is a little daunting. Any ideas?
Edit: So to clarify, I think the problem I'm seeing is due to mediator types like "performance" (an actor in a film) or "marriage". E.g., with a query about Yo La Tengo, I can see most (all?) information that I'm interested in, but a similar query about [The Muppet Movie]( freebase.com/api/service/search?limit=1&mql_output=%5B%7B%22%2Ftype%2Freflect%2Fany_reverse%22%3A%5B%7B%7D%5D%2C%22%2Ftype%2Freflect%2Fany_master%22%3A%5B%7B%7D%5D%2C%22%2Ftype%2Freflect%2Fany_value%22%3A%5B%7B%7D%5D%7D%5D&query=The%20Muppet%20Movie -- sorry, SO thinks I'm a spammer so I can't make this a link), I don't see Frank Oz reference at all (probably because his performance is referenced instead). Is there a generic way for me to "follow" mediator types to get all their properties? E.g., is there a single output MQL that would allow me to get the actor in a performance (when linked form a film search result) and give the the spouse in a marriage (when linked from a person)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不仅查询每个属性,然后在图表中深入了解这些属性以获取所有搜索结果,这将是一项非常昂贵的操作。这有什么用例?你真的有一个用户可以看到并有效吸收所有这些信息的用户界面吗?不过,为了直接回答这个问题,不可能使用搜索 API 上的 mql_output 自动解压中介类型。
我建议将有关搜索查询的一组基本信息与有关用户表示感兴趣的主题(例如通过将鼠标悬停在其上)的更深层信息组合起来。此 UI 体验与 Freebase Suggest 类似。
自从最初提出这个问题以来,已经添加了一些额外有用的东西,例如“值得注意的”伪属性,它可以让您了解该主题的值得注意之处。
当然,每个人也需要迁移到新的 API,因此查询将是:
https:// www.googleapis.com/freebase/v1/search?query=%22the%20muppet%20movie%22&limit=1&indent=true
https://www.googleapis.com/freebase/v1/topic/en/the_muppet_movie
Querying not only every property, but then following those properties another ply deep in the graph for all search results is going to be an incredibly expensive operation. What is the use case for this? Do you really have a UI where the user can see and effectively absorb all this information? To answer the question directly though, it's not possible to unpack mediator types automatically using mql_output on the search API.
I'd suggest combining a basic set of information on the search query with a deeper set of information on a topic that the user has expressed interest (e.g. by hovering over). This UI experience would be similar to that of Freebase Suggest.
In the years since the question was originally asked there have been some additional useful things added such as the "notable" pseudo-property which lets you see what the topic is notable for.
Of course everyone also needs to be moving to the new API, so the queries would be:
https://www.googleapis.com/freebase/v1/search?query=%22the%20muppet%20movie%22&limit=1&indent=true
https://www.googleapis.com/freebase/v1/topic/en/the_muppet_movie
据我所知,无法在完全的 MQL 中执行此操作,但您可以:
看这个例子:
它获取类型为actor的所有对象的所有属性、tv_actor 或名人。当您运行它时,您将看到您可以探索的所有可能的“跟随”点。
这并不完全是您想要的,但它应该会让您更接近。
AFAIK there is no way to do this in outright MQL, but you can:
Look at this example:
It grabs all the properties of all objects that have the type actor, tv_actor, or celebrity. When you run it, you'll see all the possible "follow" points you can explore.
This is not exactly what you want, but it should get you closer.