0

我希望从 Freebase 中提取旅游景点列表及其城市、州和国家/地区信息。具有位置的属性是“/location/location/containedby”。此对象有不同的类型,“位置/位置”或“/base/biblioness/bibs_location”。如果对象具有“/base/biblioness/bibs_location”,我可以获得“city”、“state”等的值。但是如果对象只有“/location/location”类型,我需要去获取它的“containedby” " 字段并重做上述逻辑。

我的问题是我可以在 Freebase 中执行条件查询,例如 if type == "/location/location/" get xyz. 如果 type== "/base/biblioness/bibs_location" 得到 abc

MQL:

[{
  "type":   "/travel/tourist_attraction",
  "id":     null,
  "name":   null,
  "name~=": "^San Diego",
  "/location/location/containedby": {
    "type": "/base/biblioness/bibs_location",
    "name": null,
    "id":   null
  },
  "/location/location/geolocation": [{
    "id":        null,
    "latitude":  null,
    "longitude": null
  }]
}]
4

1 回答 1

0

MQL doesn't support conditional logic, but you can query all the information that you're potentially interested in, making the subqueries optional so they don't filter the results, and then look at what you get back. It'll require conditional code in your result processor, but you won't have to make multiple queries. For example, you could query multiple levels of /location/location/contained by as well as /base/biblioness/bibs_location/state and whatever else you want.

Before you go spending too much time on this though, you might want to check how well populated /base/biblioness/bibs_location is. It looks to me like it's got less than 2K entities.

于 2013-06-18T22:38:09.560 回答