3

我试图弄清楚如何编写 MQL 查询以获取与给定单词关联的所有类型的列表。

例如我试过:

{
  "id":null,
  "name":null,
  "name~=": "SOME_WORD",
  "type":"/type/type",
  "domain": {
    "id": null,
    "/freebase/domain_profile/category": {
      "id": "/category/commons"
    }
  }
}​

我发现它列出了所有 Commons 类型或类别,但还没有弄清楚如何缩小给定输入的范围。

[{
  "id":   null,
  "name": null,
  "type": "/freebase/domain_profile",
  "category": {
    "id": "/category/commons"
  }
}]​
4

2 回答 2

4

有几种不同的方法可以做到这一点,每种方法都有不同的权衡。

  1. 将 Search API 与这样的查询一起使用

    https://www.googleapis.com/freebase/v1/search?indent=true&filter=%28all%20name {full}:%22uss%20constitution%22%29

您将获得如下所示的 JSON 结果:

{
  "status": "200 OK",
  "result": [
    {
      "mid": "/m/07y14",
      "name": "USS Constitution",
      "notable": {
        "name": "Ship",
        "id": "/boats/ship"
      },
      "lang": "en",
      "score": 1401.410400
    },
    ...

您可以通过将“{full}”切换为“{phrase}”来使匹配更加自由,这将为您提供子字符串匹配而不是精确匹配。

警告: - 你只会得到一个“显着类型”,它由 Freebase 的(未知)算法修复 - 我认为没有办法同时获得 USS 宪法和 USS 宪法结果 - 你可以获得所有类型的列表通过添加 &mql_output={"type":[]},但随后您将失去“显着”类型。我认为没有办法在一个电话中同时获得两者。

  1. 使用 MQL

此查询返回您想要的基本信息:

[{
  "name~=":"uss constitution",
  "type":[],
  "/common/topic/notable_types" : []
}]​

注意事项:

  • 它不会找到作为别名而不是主名称的“uss 宪法”(尽管MQL 食谱中有一个配方)
  • 它不会找到“美国宪法”
  • “notable_types” API 是 MQL 扩展,新的 Freebase API 不支持 MQL 扩展,仅支持已弃用的旧 API
  • 您与 Freebase 用于计算“知名度”的任何(未知)算法相关联

根据您要完成的工作,您可能需要比这更复杂的东西(以及对 Freebase 中的内容有更深入的了解),但这应该能让您掌握基础知识。

于 2012-03-01T16:51:00.253 回答
0

你试过了吗:

[{
"name": "David Bowie",
"type": []
}]
于 2013-08-03T19:58:38.267 回答