Freebase初学者:获得运动员的运动

时间:2012-06-13 13:36:29

标签: freebase

我正在尝试使用Freebase来找出职业运动员所属的球队。

所以我正在尝试做这样的事情

[{
  "id":   null,
  "name": "Kobe Bryant",
  "type": "/sports/pro_athlete",
  "sports_played":    []
}]​

query editor

然后提取属性“sport_played”以找出玩家属于哪种运动。我的计划是对“basketball_player”进行更具体的查询,直到我找到团队名称。 (这是一种更简单的方法吗?)

但是,我在第一步失败了,因为在结果中,虽然属性sport_played和sport_played_professionally包含一个条目,但该条目为null:

{
  "code":          "/api/status/ok",
  "result": [{
    "id":   "/en/kobe_bryant",
    "name": "Kobe Bryant",
    "sports_played": [
      null
    ],
    "type": "/sports/pro_athlete"
  }],
  "status":        "200 OK",
  "transaction_id": "cache;cache03.p01.sjc1:8101;2012-06-13T13:30:20Z;0053"
}

我很困惑:我从浏览数据库知道这个玩家应该有运动价值。结果清楚地表明结果中“sports_played”列表中有一个值。

但为什么它是空的?难道不应该是篮球对象的参考吗?

2 个答案:

答案 0 :(得分:0)

您的查询要求提供sports_played列表,但由于您只使用方括号,因此只会返回所有匹配主题的名称列表。

如果你在查询中添加大括号,你会看到sports_played实际上返回一个名称为null的主题(这是你之前的查询显示的内容)

[{
  "id": null,
  "name": "Kobe Bryant",
  "type": "/sports/pro_athlete",
  "sports_played": [{}]
}]

这是因为expected value of sports_played是名为CVTSports played,它将运动员与特定时期的运动联系起来。这样我们就可以跟踪已经参加多项运动的运动员,并了解哪一项是最新的运动员。

如果要查看CVT对象内的值,则需要进一步向下钻取:

[{
  "id": null,
  "name": "Kobe Bryant",
  "type": "/sports/pro_athlete",
  "sports_played": [{
    "type": "/sports/pro_sports_played",
    "sport": {
      "id": null,
      "name": null
    },
    "career_start": null,
    "career_end": null
  }]
}]

Query Editor

中试用

答案 1 :(得分:0)

sports_played属性并不是您想要的,因为它不一定与包含团队信息的属性相关联。

相反,你想要使用以下内容:

{
  "id":   null,
  "name": "Kobe Bryant",
  "/basketball/basketball_player/team" : [{"team":null}],
  }]
}

如果您希望获得所有Kobe Bryants的所有团队,您可以使用以下内容:

[{
  "id":   null,
  "name": "Kobe Bryant",
  "/soccer/football_player/current_team" : [{"team":null,"optional":true}],
  "/basketball/basketball_player/team" : [{"team":null,"optional":true}],
  "/american_football/football_player/current_team" :[{"team":null,"optional":true}]
  }]
}]​

不幸的是,您需要手动完成架构并手动拉出感兴趣的属性,因为它们不够可靠,不能自动查询,但实际上并没有那么多运动需要考虑,所以它不应该花很长时间来组装你的清单。