在 Freebase 中检索/存储所有相关的 Actor [英] Retrieving/storing All related Actors in Freebase

查看:22
本文介绍了在 Freebase 中检索/存储所有相关的 Actor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做一些(应该)非常简单的事情.也许我错过了什么.

I'm trying to do something that (should be) very simple. Maybe I'm missing something.

我想获得一个人共事过的完整列表.我的最终目标是找到他最常合作的人(无论关系如何)

I want to get a full list of people a person has worked with. My end goal is to find who he works with most often (in whatever relationship that may be)

例如:Robert De Niro 曾与乔·佩西 (Joe Pesci) 合作过 7 次,但导演了他两次.结果我想要一个包含 9 个条目的表格.

Ex: Robert De Niro has acted together with Joe Pesci 7 times, but directed him twice. I want a table with 9 entries as a result.

我可以使用主题 API,但它只返回电影列表.然后我必须执行 10 多个 API 查询来获取每部电影的演员表.需要永远,代码是一场噩梦.

I can use the topic API, but that only returns a list of movies. I then have to perform 10+ API queries to get the cast of every movie. Takes forever and the code is a nightmare.

如果我使用 MQL 搜索,我只能搜索Robert De Niro主演的电影,而不是他导演、编写或制作的每部电影, or 主演.基本上我一次只能搜索 1 个角色.

If I use MQL search, I can only search for movies that Robert De Niro has starred in, but not every movie he has directed, or written, or produced, or starred in. Basically I can only search by 1 role at a time.

有没有更好的办法?我需要得到一个列表:

Is there a better way? I need to end up with a list of:

电影

演员/剧组人员

Roles 链接 MoviesPeople

我目前在做什么:

  • 搜索 Robert De Niro 并获取机器 ID
  • 对该 MID 进行主题搜索,返回他参与过的电影 MID 列表
  • 对每部电影 MID 进行主题搜索,并记录directed_by、starring、produced_by 等字段

如您所见,这是一项非常昂贵的操作.以这种方式避免重复也极其困难(尽管我正在努力)

As you can see it's a very expensive operation. It's also extremely difficult to avoid duplicates in this way (though I'm working on it)

这是我当前的 MQL 查询(出于某种原因,它仅在我指定两个参与者名称时才有效,但这是另一个问题.

edit: Here's my current MQL query (for some reason it only works if I specify two actor names, as well, but that's another issue.

$query = array(array(
                        'a:starring'=>array('actor'=>'Joe Pesci'),
                        'b:starring'=>array('actor'=>'Robert De Niro'),
                        'directed_by'=>null,
                        'produced_by'=>array(),
                        'written_by'=>array(),
                        'executive_produced_by'=>array(),
                            'name'=>null,
                            'mid'=>null,
                        'starring'=>array(array('actor'=>array('mid'=>null,
                                   'name'=>null))),
                        'type'=>'/film/film'
                        ));

MQL:

    [{
    "a:starring":
        {"actor":"Joe Pesci"},
    "b:starring":
        {"actor":"Robert De Niro"},
    "directed_by":null,
    "produced_by":[],
    "written_by":[],
    "executive_produced_by":[],
    "name":null,
    "mid":null,
    "starring":
        [{"actor":
            {"mid":null,"name":null}}],
    "type":"\/film\/film"}]

推荐答案

您可以在单个 MQL 查询中完成这一切,并为定向/写入/执行属性提供不同的子查询.只要确保每个子查询都是可选的.

You can do this all in a single MQL query with different subqueries for the directed/wrote/acted in properties. Just make sure you make each subquery optional.

例如:

[{
  "a:starring": {
    "actor": "Joe Pesci"
  },
  "b:starring": {
    "actor": "Robert De Niro"
  },
  "directed_by": [{
    "id": null,
    "name": null,
    "optional": true
  }],
  "produced_by": [{
    "id": null,
    "name": null,
    "optional": true
  }],
  "written_by": [{
    "id": null,
    "name": null,
    "optional": true
  }],
  "executive_produced_by": [{
    "id": null,
    "name": null,
    "optional": true
  }],
  "name": null,
  "mid": null,
  "starring": [{
    "actor": {
      "mid": null,
      "name": null
    }
  }],
  "type": "/film/film"
}]

这篇关于在 Freebase 中检索/存储所有相关的 Actor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆