从数据转储或 Freebase API 中获取演员 ID 和传记 [英] Gettting Actor Ids and biographies from the data dumps or Freebase API

查看:29
本文介绍了从数据转储或 Freebase API 中获取演员 ID 和传记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道从 Freebase 数据转储中获取 Actor Id 的最佳方法,然后再从 Freebase API 获取 IMDB id 和传记?

Does anyone know the best way of getting Actor Ids from Freebase data dumps, and later on getting the IMDB ids and biographies from the Freebase API?

推荐答案

Actors 将具有/film/actor 类型,并且在转储中看起来像这样:

Actors will have the type /film/actor and look like this in the dump:

ns:m.010q36     rdf:type        ns:film.actor.

您可以在几分钟内使用简单的 grep 从压缩转储中找到它们:

You can find them all in a few minutes from the compressed dump with a simple grep:

zgrep $'rdf:type\tns:film.actor.' freebase-rdf-<date of dump>.gz | cut -f 1 | cut -d ':' -f 2 > actor-mids.txt

这将生成一个格式为 m.010q36 的 MID 列表,代表 MID /m/010q36.

This will generate a list of MIDs in the form m.010q36 which represents the MID /m/010q36.

使用 MID 列表,在第一列中查找具有该 MID 的所有行,在第二列中查找您想要的属性之一.您可以使用 Python、grep 或您选择的工具/语言来执行此操作.当然,如果您使用的是 Python 之类的编程语言,则可以进行初始搜索.

Using the list of MIDs, look for all lines which have that MID in the first column, one of your desired properties in the second. You could do this using Python, grep, or the tool/language of your choice. Of course if you're using a programming language like Python, you could roll the initial search.

维基百科和 IMDB ID 被存储为 Freebase 所称的密钥,看起来像这样(MusicBrainz 和 Netflix 也包括在内):

Wikipedia and IMDB IDs are stored as what Freebase calls keys and look like this (MusicBrainz & Netflix included too):

ns:m.010q36     ns:type.object.key      "/wikipedia/en/Mr$002ERodgers".
ns:m.010q36     ns:type.object.key      "/authority/imdb/name/nm0736872".
ns:m.010q36     ns:type.object.key      "/authority/musicbrainz/87467525-3724-412d-ad3e-595ecb6a3bfd".
ns:m.010q36     ns:type.object.key      "/authority/netflix/role/30006685".

密钥可以被编码(如上面的维基百科密钥).您可以在 Freebase wiki 上找到有关如何处理它们的文档.

Keys may be encoded (like the Wikipedia key above). You can find documentation on the Freebase wiki on how to deal with them.

这篇关于从数据转储或 Freebase API 中获取演员 ID 和传记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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