query-9a77f3f591e48880804687a0d030af2b
?sampleSense?anyGloss TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?lexeme (GROUP_CONCAT(DISTINCT ?lemma; separator = "/") AS ?lemmata) ?sampleSense (SAMPLE(?gloss) AS ?anyGloss)
WHERE {
{
SELECT ?lexeme (SAMPLE(?sense) AS ?sampleSense) WHERE {
SERVICE bd:sample {
?lexeme dct:language wd:Q8752.
bd:serviceParam bd:sample.limit 20 .
}
OPTIONAL { ?lexeme ontolex:sense ?sense. }
}
GROUP BY ?lexeme
}
?lexeme wikibase:lemma ?lemma.
BIND(BOUND(?sampleSense) AS ?haveSampleSense) # if ?sampleSense is unbound, the result of the below OPTIONAL is meaningless
BIND(?sampleSense AS ?sampleSense_) # copy of ?sampleSense that can be bound without harm (not included in GROUP BY / SELECT)
OPTIONAL { ?sampleSense_ skos:definition ?gloss_. } # if ?sampleSense_ was unbound, it is now bound to any sense of any gloss
BIND(IF(?haveSampleSense, ?gloss_, ?unbound) AS ?gloss) # use the gloss only if it belongs to the already known ?sampleSense
}
GROUP BY ?lexeme ?sampleSense
Query found at
- https://www.wikidata.org/wiki/User:Infovarius/Queries
- https://www.wikidata.org/wiki/Wikidata:Request_a_query/Archive/2020/03
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v10("?anyGloss")
v8("?gloss"):::projected
v7("?gloss_")
v5("?haveSampleSense")
v4("?lemma"):::projected
v9("?lemmata")
v1("?lexeme"):::projected
v3("?sampleSense"):::projected
v6("?sampleSense_")
v2("?sense")
c3(["wd:Q8752"]):::iri
c4(["bd:serviceParam"]):::iri
c6(["20^^xsd:integer"]):::literal
subgraph s1["http://www.bigdata.com/rdf#sample"]
style s1 stroke-width:4px;
v1 --"dct:language"--> c3
c4 --"bd:sample.limit"--> c6
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."ontolex:sense".-> v2
end
bind1[/"sample(?sense)"/]
v2 --o bind1
bind1 --as--o v3
v1 --"wikibase:lemma"--> v4
bind2[/"bound(?sampleSense)"/]
v3 --o bind2
bind2 --as--o v5
bind3[/"?sampleSense"/]
v3 --o bind3
bind3 --as--o v6
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v6 -."skos:definition".-> v7
end
bind4[/"if(?haveSampleSense,?gloss_,?unbound)"/]
v5 --o bind4
v7 --o bind4
null --o bind4
bind4 --as--o v8
bind7[/"?lemma"/]
v4 --o bind7
bind7 --as--o v9
bind8[/"sample(?gloss)"/]
v8 --o bind8
bind8 --as--o v10