【发布时间】:2019-03-28 12:38:53
【问题描述】:
我想获取为特定球队效力的球员以及在特定日期之后出生的球员的职业信息。我设法做了以下查询:
select ?playerName ?year ?teamName ?matches ?goals where {
?player a dbo:SoccerPlayer ;
rdfs:label ?playerName ;
dbo:birthDate ?birthDate ;
dbo:careerStation ?station .
?station dbo:years ?year ;
dbo:team ?team ;
dbo:team/rdfs:label ?teamName ;
dbo:numberOfMatches ?matches ;
dbo:numberOfGoals ?goals .
filter (langMatches(lang(?teamName), "EN"))
filter (xsd:date(?birthDate) > "1980-01-01"^^xsd:date)
filter (
?team = <http://dbpedia.org/resource/Olympique_Lyonnais>
|| ?team = <http://dbpedia.org/resource/AS_Monaco_FC>
)
}
order by ?playerName ?year
我的问题是:
- 我只得到与球员实际为过滤球队效力的年份相对应的年份,我想拥有他的全部职业生涯
- 有很多行重复,我不知道为什么
-
某些行与我的过滤器不对应。示例:
"Gaëtan Perrin"@en | 2014... | "Olympique Lyonnais Reserves and Academy"@en | 3 | 1
感谢您的帮助!
【问题讨论】:
-
您想为球队获得球员的所有进球吗?因为你写了 "I only get the years 对应于玩家的年份" - 我想应该是 "I only get the goals 对应玩家的年份” - 我说的对吗?如果没有,你能举个例子吗?
-
我们以亚历山大·拉卡泽特为例。他曾为 Olympique Lyonnais 效力,并且出生于 1980 年 1 月 1 日之后,因此必须将他考虑在内。对于这位球员,我想拥有所有的职业生涯(在里昂奥林匹克和其他地方)
-
不确定这是不是你想要的:
select ?playerName ?teamName (sum(?_matches) as ?matches) (sum(?_goals) as ?goals) where { ?player a dbo:SoccerPlayer ; rdfs:label ?playerName ; dbo:birthDate ?birthDate ;dbo:careerStation ?station . ?station dbo:years ?year ; dbo:team ?team ; dbo:team/rdfs:label ?teamName ;dbo:numberOfMatches ?_matches -
;dbo:numberOfGoals ?_goals . filter (langMatches(lang(?teamName), "EN")) filter (xsd:date(?birthDate) > "1980-01-01"^^xsd:date) filter (?team = <http://dbpedia.org/resource/Olympique_Lyonnais> || ?team = <http://dbpedia.org/resource/AS_Monaco_FC> )} group by ?playerName ?teamName order by ?playerName (max(?year)) -
显然有一个限制,当一个球员在不同的时间段为同一支球队效力时,例如
2012 - 2014和2016 - 2017,上面的查询无法区分