简体   繁体   English

遍历 Freebase 图

[英]Traversing the Freebase Graph

I'm trying to fetch multiple levels of influence relationships from a particular person.我试图从一个特定的人那里获取多层次的影响关系。 Roughly, this query explains what I'm trying to accomplish粗略地说,这个查询解释了我想要完成的事情

{ "id" : "/en/george_orwell",
  "name" : null,
  "type" : "/influence/influence_node",
  "influenced": [{"id": null,"name" : null,
                  "type" : "/influence/influence_node",
                   "influenced": [{"id": null,"name" : null,
                                   "type" : "/influence/influence_node",
                                   "influenced": [{"id": null,"name" : null}],
                                   "influenced_by": [ { "id": null, "name" : null}] }],
                  "influenced_by": [ {"id": null,"name" : null,
                                   "type" : "/influence/influence_node",
                                   "influenced": [{"id": null,"name" : null}],
                                   "influenced_by": [ { "id": null, "name" : null}] }],
  "influenced_by": [{"id": null,"name" : null,
                  "type" : "/influence/influence_node",
                  "influenced": [{"id": null,"name" : null,
                                   "type" : "/influence/influence_node",
                                   "influenced": [{"id": null,"name" : null}],
                                   "influenced_by": [ { "id": null, "name" : null}] }],
                  "influenced_by": [ {"id": null,"name" : null,
                                   "type" : "/influence/influence_node",
                                   "influenced": [{"id": null,"name" : null}],
                                   "influenced_by": [ { "id": null, "name" : null}] }] }

Is there any efficient way of traversing the Freebase graph using MQL?有没有使用 MQL 遍历 Freebase 图的有效方法?

I assume you want to get influenced and influenced_by for a given number of plies out?我假设您想在给定数量的层数上受到影响和影响? No it's not possible to do this in mql, it would require some sort of recursion and self-referencing.不,在 mql 中不可能做到这一点,它需要某种递归和自引用。

However, you can pass multiple ids using this syntax [{ 'id|=': ['id1', 'id2', ...] }]但是,您可以使用以下语法传递多个 id [{ 'id|=': ['id1', 'id2', ...] }]

In that way you can get the list of people from running the query the first time given a seed, and then re-run the query to crawl the graph for any given id selected.通过这种方式,您可以在给定种子的第一次运行查询时获取人员列表,然后重新运行查询以抓取所选任何给定 id 的图形。

If this is not aimed to be done interactively (by a person) then you should probably use the freebase data dumps to pre-calculate the whole thing offline.如果这不是要以交互方式(由一个人)完成,那么您可能应该使用 freebase 数据转储来离线预先计算整个事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM