Help

Difference between revisions of "SPARQL"

Line 229: Line 229:
  
 
== Langue + speaker + word → Audio's Qid ==
 
== Langue + speaker + word → Audio's Qid ==
 +
 +
{|
 +
|- style="vertical-align:top;"
 +
|style="padding: 0 3em;width:60%"|
 +
<syntaxhighlight lang="sparql">
 +
SELECT ?audio WHERE {
 +
  ?audio prop:P4 entity:Q209 . #language
 +
  ?audio prop:P5 entity:Q584098 . #speaker
 +
  ?audio rdfs:label ?word . #word
 +
  FILTER ( STR(?word) = "ni" )
 +
}
 +
</syntaxhighlight>
 +
||
 +
<query _pagination="5" >
 +
SELECT ?audio WHERE {
 +
  ?audio prop:P4 entity:Q209 . #language
 +
  ?audio prop:P5 entity:Q584098 . #speaker
 +
  ?audio rdfs:label ?word . #word
 +
  FILTER ( STR(?word) = "ni" )
 +
}
 +
</query>
 +
|}
 +
 
== Audio Qid → Audio data ==
 
== Audio Qid → Audio data ==
 
== ✅ Langue + speaker + word → Audio's Commons url  ==
 
== ✅ Langue + speaker + word → Audio's Commons url  ==

Revision as of 19:12, 5 December 2021

Base

✅ Is Sex or Gender(sex or gender (Q7)) → list all possible values

SELECT ?item ?itemLabel
WHERE {
  ?item prop:P2/prop:P9 * entity:Q7
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
  } 
}
... Loading ...

✅ Is Speaker (speaker (Q3)) → list all speakers

select ?speaker ?speakerLabel
where {
  ?speaker prop:P2 entity:Q3 .
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
  } 
}
... Loading ...

Speaker name → Speaker Qid

select ?speakerName ?speakerId
where {
  VALUES ?speakerName { "Yug" "VIGNERON" } #One or multiple values are acceptable here
  BIND ( STRLANG(?speakerName, "en") AS ?speakerLabel )
  ?speakerId prop:P2 entity:Q3 ; rdfs:label ?speakerLabel .
}
... Loading ...

Speaker Qid (0x010C (Q42)) → Speaker data

SELECT ?predicate ?object
WHERE {
  entity:Q42 ?predicate ?object .
}
... Loading ...

Speaker Qid → Speaker data → speaker languages

SELECT ?languages
WHERE {
  entity:Q42 prop:P4 ?languages .
}
... Loading ...

Speaker Qid + language → list of all associated audios

SELECT ?audio WHERE {
  ?audio prop:P5 entity:Q42 .
  ?audio prop:P4 entity:Q21 .
}
... Loading ...

Is Language (speaker (Q3)) → list all languages with number of unique words and speakers

SELECT ?language (COUNT(?audio) AS ?nbAudio) (COUNT(?speaker) AS ?nbSpeaker) WHERE {
  ?language prop:P2 entity:Q4 .
  ?audio prop:P4 ?language .
  ?speaker prop:P4 ?language .
}
GROUP BY ?language

Too large to work :(

Isolang → Language LL Qid

SELECT * WHERE {
  ?lang prop:P13 ?code .
}
... Loading ...

Isolang → Language WD Qid

SELECT * WHERE {
  ?lang prop:P12 ?idWikidata .
}
... Loading ...

Language WD Qid → Language data

SELECT * WHERE {
  ?lang prop:P12 "Q12107" .
  ?lang ?predicate ?object .
}
... Loading ...

Language LL Qid → Language data

SELECT * WHERE {
  entity:Q209 ?predicate ?object .
}
... Loading ...

Langue + speaker + word → Audio's Qid

SELECT ?audio WHERE {
  ?audio prop:P4 entity:Q209 . #language
  ?audio prop:P5 entity:Q584098 . #speaker
  ?audio rdfs:label ?word . #word
  FILTER ( STR(?word) = "ni" )
}
... Loading ...

Audio Qid → Audio data

✅ Langue + speaker + word → Audio's Commons url

Tools