【问题标题】:Freebase beginner: getting an athlete's sportFreebase初学者:获得运动员的运动
【发布时间】:2012-06-13 13:36:28
【问题描述】:

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

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

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

query editor

然后提取属性“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”列表中有一个值。

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

【问题讨论】:

    标签: freebase


    【解决方案1】:

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

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

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

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

    如果您想查看 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试试吧

    【讨论】:

      【解决方案2】:

      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}]
        }]
      }]​
      

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-05-03
        • 1970-01-01
        • 2018-06-18
        • 2019-01-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多