检索/存储中游离碱的所有相关行动者 [英] Retrieving/storing All related Actors in Freebase

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

问题描述

我试图做一些事情,(应该是)非常简单。也许我失去了一些东西。

我想要得到的人的人曾与一个完整列表。我的最终目标是要找到他最常作品谁(不论关系可能)

例如:罗伯特·德尼罗已与乔·佩西7次联合行动,而是指示他两次。我希望有一个表记录了9个结果。

我可以使用主题的API,但是这仅返回电影列表。然后,我必须执行10+ API查询获取每部电影的演员。需要永远和code是一个噩梦。

如果我用MQL搜索,我只能搜索该罗伯特·德尼罗的出演电影,但不是每部电影,他曾执导过,或书面的,或生产的的出演,基本上我可以通过1角色一次只能搜索。

有没有更好的办法?我需要的列表,以结束:

电影

演员/船员人们

角色链接电影

我目前做的:


  • 搜索罗伯特·德尼罗并获得计算机ID

  • 请针对MID的话题搜索,返回的MID电影的名单,他曾经参与过

  • 请每部电影中旬的主题搜索,并记录字段,如directed_by,主演,produced_by等

正如你可以看到它是一个非常昂贵的操作。这也是非常难以避免这样的重复(虽然我的工作就可以了)

编辑:这是我目前的MQL查询(出于某种原因,如果我指定两位男主角的名字,以及它才能正常运行,但这是另外一个问题。

  $查询=阵列(阵列(
                        答:主演'=>阵列('演员'=>'乔·佩西'),
                        'B:主演'=>阵列('演员'=>'罗伯特·德尼罗),
                        directed_by'=>空,
                        produced_by'=>阵()
                        written_by'=>阵()
                        executive_produced_by'=>阵()
                            '名'=>空,
                            MID=>空,
                        '主演'=>阵列(阵列('演员'=>阵列('中间'=>空,
                                   '名'=> NULL)))
                        '型'= GT;'/电影/电影
                        ));

在MQL:

  [{
    答:主演:
        {演员:乔·佩西},
    B:主演:
        {演员:罗伯特·德尼罗},
    directed_by:空,
    由。。。生产:[],
    written_by:[],
    executive_produced_by:[],
    名:空,
    MID:空,
    主演:
        [{演员:
            {MID:空,名:空}}],
    类型:\\ /片\\ /电影}]


解决方案

您可以做到这一切在一个单一的MQL查询与不同的子查询定向/写/演过的属性。只要确保你让每个子查询可选的。

例如:

  [{
  答:主演:{
    演员:乔·佩西
  },
  B:主演:{
    演员:罗伯特·德尼罗
  },
  由...主持: [{
    ID:空,
    名:空,
    可选:真
  }],
  由。。。生产: [{
    ID:空,
    名:空,
    可选:真
  }],
  written_by:[{
    ID:空,
    名:空,
    可选:真
  }],
  executive_produced_by:[{
    ID:空,
    名:空,
    可选:真
  }],
  名:空,
  MID:空,
  主演:[{
    演员:{
      MID:空,
      名:空
    }
  }],
  类型:/电影/电影
}]

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"}]

解决方案

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"
}]

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

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