freebase MQL会对此进行什么查询?

时间:2012-11-15 09:20:44

标签: freebase mql

我想找到IBM的首席执行官。什么是MQL查询呢?

1 个答案:

答案 0 :(得分:1)

此搜索的MQL如下所示 这个特殊的实例可能比必要的更复杂,因为我最初是通过Freebase交互式搜索生成的,然后手动添加/改进过滤器。
我使用各种公司名称验证了相对成功,即如果基础数据在Freebase中正确编码(有些公司缺失,某些公司的领导数据不完整等),则可行。 这个查询有一些技巧:

  • u0 fitler中的公司名称需要与Freebase 中记录的公司名称​​精确匹配。您可以使用contains谓词而不是equal谓词,但这可能会引入许多不相关的命中。例如,您需要使用“IBM”,“Apple Inc.”,“通用汽车”而不是这些名称的常用替代品(“国际商业机器”,“Apple”,“GM”......“)
  • 领导角色上的u1过滤器以广泛的One of谓词表示,因为不幸的是,这些角色的命名相对宽松,有重复(例如可能是CEOChief Executive Officer)以及首席执行官的角色经常与其他公司角色(如董事会主席和/或总裁等)相结合。我先挑选这个列表up(在Freebase中)包含“CEO”或“首席执行官”的领导角色的实例。
  • u2过滤器表示to日期应为空,仅选择当前在职人员,而不是前CEO(希望Freebase记录其任期结束日期)

根据您的应用程序,您可能需要测试查询是否返回一条且只有一条记录,如果没有,则进行相应调整。

Freebase MQL editor是一种方便的工具测试和编辑方式。

[
  {
    "from": null,
    "id": null,
    "limit": 20,
    "organization": {
      "id": null,
      "name": null,
      "optional": true
    },
    "person": {
      "id": null,
      "name": null,
      "optional": true
    },
    "role": {
      "id": null,
      "name": null,
      "optional": true
    },
    "s0:type": [
      {
        "id": "/organization/leadership",
        "link": [
          {
            "timestamp": [
              {
                "optional": true,
                "type": "/type/datetime",
                "value": null
              }
            ],
            "type": "/type/link"
          }
        ],
        "type": "/type/type"
      }
    ],
    "sort": "s0:type.link.timestamp.value",
    "title": null,
    "to": null,
    "type": "/organization/leadership",
    "u0:organization": [
      {
        "id": null,
        "name": "IBM",
        "type": "/organization/organization"
      }
    ],
    "u1:role": [
      {
        "id": null,
        "name|=": ["Chief Executive Officer", "President and CEO", "Chairman and CEO", "Interim CEO", "Interim Chief Executive Officer", "Founder and CEO", "Chairman, President and CEO", "Managing Director and CEO", "Executive Vice President and Chief Operating Officer", "Co-Founder, Chairman and Chief Executive Officer"],
        "type": "/organization/role"
      }
    ],
    "u2:to": [
      {
      "value": null,
      "optional": "forbidden"
      }
    ]
  }
]​

示例返回(对于“IBM”,特别是)

{
  "code":          "/api/status/ok",
  "result": [{
    "from":  "2012-01-01",
    "id":    "/m/09t7b08",
    "organization": {
      "id":   "/en/ibm",
      "name": "IBM"
    },
    "person": {
      "id":   "/en/virginia_m_rometty",
      "name": "Virginia M. Rometty"
    },
    "role": {
      "id":   "/en/chairman_president_and_ceo",
      "name": "Chairman, President and CEO"
    },
    "s0:type": [{
      "id":   "/organization/leadership",
      "link": [{
        "timestamp": [{
          "type":  "/type/datetime",
          "value": "2010-01-23T08:02:57.0006Z"
        }],
        "type": "/type/link"
      }],
      "type": "/type/type"
    }],
    "title": "Chairman, President and CEO",
    "to":    null,
    "type":  "/organization/leadership",
    "u0:organization": [{
      "id":   "/en/ibm",
      "name": "IBM",
      "type": "/organization/organization"
    }],
    "u1:role": [{
      "id":   "/en/chairman_president_and_ceo",
      "type": "/organization/role"
    }],
    "u2:to": []
  }