编写Freebase MQL查询,获取有关给定主题的所有内容?

时间:2021-07-06 13:09:41

I want to write a query that gets back everything that is known about a topic (only needs to be one level deep.

我想编写一个查询来获取有关某个主题的所有知识(只需要深入一级)。

When working in the Freebase MQL Editor they give the following example for "Everything we know about Jimi Hendrix":

在Freebase MQL编辑器中工作时,他们给出了“我们所知道的关于Jimi Hendrix的一切”的以下示例:

{
  "*" : null,
  "name" : "Jimi Hendrix",
  "type" : "/music/artist"
}

The problem is that the query is bound to a type "/music/artist" and is only getting back properties that relate to that type. If you change the query to use a different type you get an entirely different result set.

问题是查询绑定到“/ music / artist”类型,并且只返回与该类型相关的属性。如果将查询更改为使用其他类型,则会得到完全不同的结果集。

{
  "*" : null,
  "name" : "Jimi Hendrix",
  "type" : "/people/person"
}

How can I write a query that really gets back everything that Freebase knows about Jimi Hendrix?

我如何编写一个真正可以获取Freebase了解Jimi Hendrix所有内容的查询?

3 个解决方案

#1


The Freebase Topic API might be what you're after:

Freebase Topic API可能就是您所追求的:

http://www.freebase.com/experimental/topic/standard?id=/en/jimi_hendrix

The Topic API will grab all properties directly related to a topic in the graph. The API wraps a series of MQL queries to get all the data and outputs in JSON.

Topic API将获取与图中主题直接相关的所有属性。 API包装了一系列MQL查询以获取JSON中的所有数据和输出。

Google "Freebase Topic HTTP API" for further information.

谷歌“Freebase主题HTTP API”获取更多信息。

#2


To do this you'll need a more advanced type of query that looks at the underlying links (/type/link) that make up the Freebase graph. Each link has a source, a target and a property assigned to it and they can be queried like this:

为此,您需要一种更高级的查询类型,查看构成Freebase图形的底层链接(/ type / link)。每个链接都有一个源,一个目标和一个分配给它的属性,可以像这样查询它们:

[
  {
    "master_property" : null,
    "source" : {
      "id" : "/en/jimi_hendrix"
    },
    "target" : null,
    "target_value" : null,
    "type" : "/type/link"
  }
]

These are called the outgoing links and represent most of the values that you usually see in the Freebase UI but you can also swap the source and target to get a list of incoming links links this:

这些被称为外向链接并代表您通常在Freebase UI中看到的大多数值,但您也可以交换源和目标以获取传入链接的列表链接:

[
  {
    "master_property" : null,
    "source" : null,
    "target" : {
      "id" : "/en/jimi_hendrix"
    },
    "type" : "/type/link"
  }
]

These links include properties on other topics that refer to Jimi Hendrix as their value and these values are not all shown on the Freebase Jimi Hendrix page to keep the volume of information to a manageable level.

这些链接包括其他主题的属性,这些主题将Jimi Hendrix作为其值,并且这些值并未全部显示在Freebase Jimi Hendrix页面上,以便将信息量保持在可管理的水平。

#3


After a while, we figured this is a typical use case, so we introduce a whole new API for doing this:

过了一会儿,我们认为这是一个典型的用例,所以我们为此做了一个全新的API:

http://www.freebase.com/docs/topic_api

This will get you all the properties from the above queries, as well as mediators and other goodies.

这将为您提供上述查询的所有属性,以及调解员和其他好东西。

Note that if you want all the properties from ALL the topics in Freebase, you should be using the data dumps and not the run-time query language (it will be many times faster).

请注意,如果您想要Freebase中所有主题的所有属性,您应该使用数据转储而不是运行时查询语言(它会快很多倍)。

#1


The Freebase Topic API might be what you're after:

Freebase Topic API可能就是您所追求的:

http://www.freebase.com/experimental/topic/standard?id=/en/jimi_hendrix

The Topic API will grab all properties directly related to a topic in the graph. The API wraps a series of MQL queries to get all the data and outputs in JSON.

Topic API将获取与图中主题直接相关的所有属性。 API包装了一系列MQL查询以获取JSON中的所有数据和输出。

Google "Freebase Topic HTTP API" for further information.

谷歌“Freebase主题HTTP API”获取更多信息。

#2


To do this you'll need a more advanced type of query that looks at the underlying links (/type/link) that make up the Freebase graph. Each link has a source, a target and a property assigned to it and they can be queried like this:

为此,您需要一种更高级的查询类型,查看构成Freebase图形的底层链接(/ type / link)。每个链接都有一个源,一个目标和一个分配给它的属性,可以像这样查询它们:

[
  {
    "master_property" : null,
    "source" : {
      "id" : "/en/jimi_hendrix"
    },
    "target" : null,
    "target_value" : null,
    "type" : "/type/link"
  }
]

These are called the outgoing links and represent most of the values that you usually see in the Freebase UI but you can also swap the source and target to get a list of incoming links links this:

这些被称为外向链接并代表您通常在Freebase UI中看到的大多数值,但您也可以交换源和目标以获取传入链接的列表链接:

[
  {
    "master_property" : null,
    "source" : null,
    "target" : {
      "id" : "/en/jimi_hendrix"
    },
    "type" : "/type/link"
  }
]

These links include properties on other topics that refer to Jimi Hendrix as their value and these values are not all shown on the Freebase Jimi Hendrix page to keep the volume of information to a manageable level.

这些链接包括其他主题的属性,这些主题将Jimi Hendrix作为其值,并且这些值并未全部显示在Freebase Jimi Hendrix页面上,以便将信息量保持在可管理的水平。

#3


After a while, we figured this is a typical use case, so we introduce a whole new API for doing this:

过了一会儿,我们认为这是一个典型的用例,所以我们为此做了一个全新的API:

http://www.freebase.com/docs/topic_api

This will get you all the properties from the above queries, as well as mediators and other goodies.

这将为您提供上述查询的所有属性,以及调解员和其他好东西。

Note that if you want all the properties from ALL the topics in Freebase, you should be using the data dumps and not the run-time query language (it will be many times faster).

请注意,如果您想要Freebase中所有主题的所有属性,您应该使用数据转储而不是运行时查询语言(它会快很多倍)。