drmticpet66231422 2013-11-22 01:49
浏览 46
已采纳

检索/存储Freebase中的所有相关Actors

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)

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.

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.

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:

Movies

Actors/Crew People

Roles linking Movies and People

What I do currently:

  • Search for Robert De Niro and obtain the Machine ID
  • Do a topic search for that MID, returning a list of movie MIDs he has worked on
  • Do a topic search for each movie MID, and record fields like directed_by, starring, produced_by, etc

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)

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'
                        ));

The 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"}]
  • 写回答

2条回答 默认 最新

  • doushan1157 2013-11-22 03:04
    关注

    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.

    For example:

    [{
      "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"
    }]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测