1

我正在尝试查询 freebase 以查找有关特定城市的信息。

我能够找到我正在寻找的城市,但我需要获取描述内容以及一些图片。

我目前的查询是

[{
  "name":   "san francisco",
  "id":     null,
  "type":   "/location/citytown",
  "/location/location/geolocation" : [
    {
      "latitude": null,
      "longitude": null,
      "latitude>" : 36,
      "latitude<" : 38 }]
  "/common/topic/article" : [{ "id" : null, "content": null }],
  "/common/topic/image" : [{
   "id" : null,
   "optional" : true,
   "limit" : 15
  "image_caption" : []
  }]
}]

哪个返回

{
  "code":          "/api/status/ok",
  "result": [{
    "/common/topic/article": [{
      "content": null,
      "id":      "/m/0d6l_"
    }],
    "/common/topic/image": [
      {
        "id":            "/m/02929wx",
        "image_caption": []
      },
      {
        "id":            "/m/04j74y4",
        "image_caption": []
      },
      {
        "id":            "/m/04j74yh",
        "image_caption": []
      },
      {
        "id":            "/m/04j74yw",
        "image_caption": []
      },
      {
        "id":            "/m/04j74z6",
        "image_caption": []
      }
    ],
    "/location/location/geolocation": [{
      "latitude":  37.775,
      "longitude": -122.4183
    }],
    "id":   "/en/san_francisco",
    "name": "San Francisco",
    "type": "/location/citytown"
  }],
  "status":        "200 OK",
  "transaction_id": "cache;cache03.p01.sjc1:8101;2012-07-24T21:50:06Z;0029"
}

我无法获取要设置的内容值和标题。

我错过了什么吗?

4

1 回答 1

2

您在哪里找到“image_caption”属性?如果将其切换为“名称”,您应该获得图像的名称(在某些 UI 上下文中用作标题)。

文本内容不可从 MQL 获得,但您可以使用为文章返回的 ID 从旧 API 中的 BLOB 服务或新 API 中的文本 API 获取它。例如https://www.googleapis.com/freebase/v1/text/m/0d6l_

ps 如果您只想要主图像,您可以考虑使用主题 API,它会在一次调用中返回图像、名称、文本简介和一堆其他信息。 https://www.googleapis.com/freebase/v1/topic/wikipedia/en_id/49728

使用 Search API 将为您提供更可靠的名称匹配,并为您提供一个分数,该分数将告诉您查询不明确的可能性有多大(如果您获得多个匹配的分数彼此接近)。 https://www.googleapis.com/freebase/v1/search?query=%22san%20francisco%22&type=/location/citytown

于 2012-07-24T22:18:52.133 回答