1

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

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

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

查询编辑器

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

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

{
  "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”列表中有一个值。

但为什么它是空的?不应该是对篮球对象的引用吗?

4

2 回答 2

0

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

如果您在查询中添加花括号,您会看到 sports_played 实际上返回了一个 name = null 的主题(这就是您之前的查询所显示的内容)

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

这是因为sports_played 的期望值是一个名为Sportsplayed 的CVT ,它将运动员与特定时间段的运动联系起来。这样我们就可以跟踪参加过多项运动的运动员,并知道哪一项是最新的。

如果您想查看 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
  }]
}]

查询编辑器中尝试

于 2012-06-14T18:20:39.303 回答
0

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

相反,您想使用以下内容:

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

如果你想得到所有科比布莱恩特的所有球队,你可以使用类似的东西:

[{
  "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}]
  }]
}]​

不幸的是,您需要手动浏览模式并手动提取感兴趣的属性,因为它们的规则性不够可靠,无法自动查询,但确实没有那么多运动需要考虑,所以不应该整理你的清单需要很长时间。

于 2012-07-12T16:39:16.853 回答