2012-06-13 53 views
1

我想用Freebase找出一個職業運動員屬於哪個團隊。Freebase初學者:獲得運動員的運動

所以我試圖做這樣的事情

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

query editor

,然後提取屬性「sport_played」找出球員屬於什麼運動。我的計劃是,然後對「basketball_player」進行更具體的查詢,直到找到團隊名稱。 (就是做這個簡單的方法?)

不過,我已經失敗的第一步,因爲在結果,而性能sport_played和sport_played_professionally包含一個條目,該條目爲空:

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

但爲什麼它是空的?不應該是對籃球對象的引用嗎?

回答

0

您的查詢是詢問sports_played的列表,但由於您只使用了方括號,因此它只會返回所有匹配主題的名稱列表。

如果添加大括號的查詢,你會看到,實際上sports_played返回與名稱= NULL一個主題(這是你之前的查詢顯示什麼)

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

這是因爲expected value of sports_playedCVT稱爲Sports 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

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

不幸的是你我們需要手工完成這個模式,並且手動提取感興趣的屬性,因爲它們不夠可靠,無法自動查詢,但實際上並沒有太多的運動需要考慮,所以它不應該花費太多時間很長時間來組裝你的清單。