SPARQL/22
< SPARQL
SELECT
?speaker
?speakerLabel
?count
?languages
# Get pairs of speaker and languages from the list of audios
WITH {
SELECT DISTINCT
?speaker
?language
{
?audio
prop:P4 ?language;
prop:P5 ?speaker.
}
} AS %speakers
# Get the count of languages per each speaker
WITH {
SELECT
?speaker
(COUNT(?speaker) AS ?count)
{
INCLUDE %speakers.
}
GROUP BY ?speaker
ORDER BY DESC(?count)
} AS %countOfLanguagesRecordedPerSpeaker
# Get the maximum number of languages per each speaker
WITH {
SELECT
(MAX(?count) AS ?maxNumberOfLanguagesRecorded)
{
INCLUDE %countOfLanguagesRecordedPerSpeaker.
}
} AS %maxNumberOfLanguagesRecorded
# Get those speakers whose count equals the maximum number of
# languages
WITH {
SELECT
?speaker
?count
{
INCLUDE %countOfLanguagesRecordedPerSpeaker.
INCLUDE %maxNumberOfLanguagesRecorded.
FILTER(?count = ?maxNumberOfLanguagesRecorded).
}
} AS %speakersWithMostNumberOfLanguagesRecorded
# Get the languages of those speakers that have recorded audios in the
# most number of languages
WITH {
SELECT
?speaker
(GROUP_CONCAT(?languageLabel; SEPARATOR = ", ") AS ?languages)
{
INCLUDE %speakersWithMostNumberOfLanguagesRecorded.
?speaker
prop:P4 [
rdfs:label ?languageLabel
]
FILTER(LANG(?languageLabel) = "en").
}
GROUP BY ?speaker
} AS %languagesOfSpeakersWithMostNumberOfLanguagesRecorded
{
INCLUDE %speakersWithMostNumberOfLanguagesRecorded.
INCLUDE %languagesOfSpeakersWithMostNumberOfLanguagesRecorded.
?speaker rdfs:label ?speakerLabel.
FILTER(LANG(?speakerLabel) = "en")
}