query-4f0fbc2166b89fcc3c9f4fd22c682184

rq turtle/ttl

: Hi. I did two things to only have each image once: 1. Grouped by ?lemma and ?sense to avoid more than one image per sense. 2. Limited ?sense to only values in Basque to only have one ?sense per lemma. Theklan@

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
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/>
SELECT (uri(replace(str(?l), "L", "Q")) as ?item) (MD5(CONCAT(str(?item),str(RAND()))) as ?random) ?l ?hitza ?sense ?ahotsak ?elhuyar ?audio (SAMPLE(?picture_) AS ?picture) 
WHERE
{
  ?l a ontolex:LexicalEntry ; dct:language ?language ;
        wikibase:lemma ?hitza ;
        ontolex:sense ?esanahia.
  ?esanahia skos:definition ?sense;

        wdt:P5137 ?q_concept.
  ?q_concept wdt:P18 ?picture_.
  ?language wdt:P218 'eu'.
  FILTER (LANG(?sense) = 'eu')
  ?l wdt:P7559 ?ahotsak.
  ?l wdt:P6838 ?elhuyar.
  ?l wdt:P443 ?audio.
    # Exclude out of scope concepts
  MINUS {?q_concept wdt:P31 wd:Q3624078.}. # countries

  # Exclude non suitable concepts
  VALUES ?minus {
  wd:Q47092 # rape
  wd:Q198   # war
  wd:Q124490 # violence
  wd:Q170382 # revolver
  wd:Q1576   #cigar
  #... add yours here
  }.
  MINUS {?sense wdt:P5137 ?minus.}.

  # Exclude senses not suitable for young children:
  VALUES ?filter {
  wd:Q8102
  wd:Q545779
  wd:Q1521634
  wd:Q571571
  wd:Q184439}.
  FILTER NOT EXISTS {?sense wdt:P6191 ?filter.}.
}
GROUP BY ?l ?sense ?hitza ?ahotsak ?elhuyar ?audio
ORDER BY ?random
LIMIT 10

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v10("?ahotsak"):::projected v12("?audio"):::projected v11("?elhuyar"):::projected v7("?esanahia") v14("?filter") v6("?hitza"):::projected v14("?item"):::projected v4("?l"):::projected v5("?language") v13("?minus") v15("?picture") v9("?picture_"):::projected v8("?q_concept") v15("?random") v2("?sense"):::projected c4(["ontolex:LexicalEntry"]):::iri c2(["eu"]):::literal c16(["wd:Q3624078"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"wdt:P6191"--> e0v2 e0v2("?filter"):::projected e0v1("?sense"):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> v14 v2 --"wdt:P6191"--> v14 f1[["?sense = 'eu'"]] f1 --> v2 v4 --"a"--> c4 v4 --"dct:language"--> v5 v4 --"wikibase:lemma"--> v6 v4 --"ontolex:sense"--> v7 v7 --"skos:definition"--> v2 v7 --"wdt:P5137"--> v8 v8 --"wdt:P18"--> v9 v5 --"wdt:P218"--> c2 v4 --"wdt:P7559"--> v10 v4 --"wdt:P6838"--> v11 v4 --"wdt:P443"--> v12 subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v8 --"wdt:P31"--> c16 end bind3[/VALUES ?minus/] bind3-->v13 bind30(["wd:Q47092"]) bind30 --> bind3 bind31(["wd:Q198"]) bind31 --> bind3 bind32(["wd:Q124490"]) bind32 --> bind3 bind33(["wd:Q170382"]) bind33 --> bind3 bind34(["wd:Q1576"]) bind34 --> bind3 subgraph minus4["MINUS"] style minus4 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P5137"--> v13 end bind5[/VALUES ?filter/] bind5-->v14 bind50(["wd:Q8102"]) bind50 --> bind5 bind51(["wd:Q545779"]) bind51 --> bind5 bind52(["wd:Q1521634"]) bind52 --> bind5 bind53(["wd:Q571571"]) bind53 --> bind5 bind54(["wd:Q184439"]) bind54 --> bind5 bind7[/"replace(str(?l),'L','Q')"/] v4 --o bind7 bind7 --as--o v14 bind8[/"MD5(concat(str(?item),str(RAND())))"/] v14 --o bind8 bind8 --as--o v15 bind9[/"sample(?picture_)"/] v9 --o bind9 bind9 --as--o v15