Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Kommentteihin kohdistuva haku

...

Code Block
#Haetaan käsitteitä, joilla on kommentti

...


SELECT *

...


WHERE {

...


    ?subject rdfs:comment ?comment .

...


}

Pienellä kirjaimella alkavat kommentit

Code Block
# Haetaan kaikki kommentit, jotka alkavat pienellä kirjaimella

...



SELECT * WHERE {

...


  ?sub rdfs:comment ?obj .

...


  FILTER(REGEX(STR(?obj), "^[a-zäö]"))

...


}

Comment- tai YsaComment-kentässä "vuodesta" tai "vuoteen"

Code Block
SELECT *

...


#SELECT count(?l)

...


WHERE {

...


{

...


    ?s yso-meta:ysaComment ?l .

...


    FILTER(regex(lcase(?l), "vuodesta|vuoteen"))

...


}

...


UNION

...


{

...


    ?s rdfs:comment ?l .

...


    FILTER(regex(lcase(?l), "vuodesta|vuoteen"))

...


}

...


}

Haku tietyn URIn perusteella

Code Block
# Huom! Dollarimerkki ei ole osa URIa, mutta on tärkeä lisätä URIn perään

...



SELECT *

...


WHERE {

...


    ?subject a ysometa:Concept .

...


FILTER regex(str(?subject), "

...

^http://www.yso.fi/onto/yso/

...

p30149$") .

...


}

Rajaus URIn / nimiavaruuden perusteella (strstarts)

Code Block
# Etsi ne YSO-käsitteet, joilla on sulkutarkenne sekä exactmatch-suhde YSAan. Rajaus tehty YSA-nimiavaruudella.

...



PREFIX yso:

...

 <http://www.yso.fi/onto/yso-meta/>

...


PREFIX skos:

...

 <http://www.w3.org/2004/02/skos/

...

core#>
PREFIX ysa:

...

 <http://www.yso.fi/onto/ysa/>

...


SELECT *

...


WHERE {

...


SERVICE

...

 <http://api.finto.fi/

...

sparql> {

...


GRAPH

...

 <http://www.yso.fi/onto/yso/> {

...


?ysoconcept skos:prefLabel ?label .

...


?ysoconcept a yso:Concept .

...


FILTER (lang(?label) = 'fi')

...


FILTER (regex(?label, '\\('))

...


?ysoconcept skos:exactMatch ?ysa .

...


FILTER (strstarts(str(?ysa), str(ysa:)))

...


}

...


}

...


}



Vaihtoehtojen esittäminen kyselyssä: jokin näistä yläkäsitteistä

Hae sellaiset  JUHO-käsitteet, jotka eivät ole ekvivalentteja jonkin YSO-käsitteen kanssa ja joiden yläkäsitteenä on jokin FILTER-lausekkeessa luetelluista YSO-käsitteistä (käsitteet sisältyvät YSOn toiminta-hierarkiaan). Huom! Kysely tehty Yasguissa.

Code Block
PREFIX skos:

...

 <http://www.w3.org/2004/02/skos/

...

core#>

#SELECT (count(?sub) as ?count)

...


SELECT ?label

...


(GROUP_CONCAT(?ylalabel) as ?ylakasitteet)

...


WHERE {

...


  GRAPH

...

 <http://www.yso.fi/onto/afo/>

...


  {

...


    ?sub a

...

 <http://www.yso.fi/onto/afo-meta/

...

Concept> .

...


    ?sub skos:broader ?ylakasite .

...


    FILTER (

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p3027> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p14> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p5192> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p5427> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p649> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p6561> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p317> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p15232> ||  

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p4389> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p464> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p1452> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p2697> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p5637> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p1744> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p193> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p2375> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p976> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p889> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p5440> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p355> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p721> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p42> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p277> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p1945> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p2715> ||

...


    ?ylakasite =

...

 <http://www.yso.fi/onto/yso/

...

p2954>
   )

...


    FILTER NOT EXISTS {

...


    ?sub skos:exactMatch ?obj .

...


    }

...


    OPTIONAL {

...


   ?sub skos:prefLabel ?label .

...


   FILTER(LANGMATCHES(LANG(?label), "fi"))

...


    }

...


    OPTIONAL {

...


      ?ylakasite skos:prefLabel ?ylalabel .

...


   FILTER(LANGMATCHES(LANG(?ylalabel), "fi"))

...


  }

...


  }

...


  }

...


GROUP BY ?label ?ylakasitteet



Vaihtoehtojen esittäminen kyselyssä, versio 2: VALUES-toiminto

PTO-ontologiassa on useita käsitetyyppejä. Hae kaikki PTO-käsitteet, jotka kuuluvat toimintahierarkian alle.

Code Block
PREFIX inspire: <http://paikkatiedot.fi/def/1001000/InspireConcept>
PREFIX paikhak: <http://paikkatiedot.fi/def/1001000/PaikhakConcept>
PREFIX tsk: <http:paikkatiedot.fi/def/1001000/TskConcept>
PREFIX ryhma: <http://paikkatiedot.fi/def/1001000/InspireThematicGroup>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
#SELECT (count(?sub) as ?count) 
SELECT ?label 
(GROUP_CONCAT(?ylalabel) as ?ylakasitteet)
WHERE {
  GRAPH <http://www.yso.fi/onto/pto/> 
  {
   ?sub a ?allowed .
    VALUES ?allowed { inspire: paikhak: tsk: ryhma: }
    ?sub skos:broader+ <http://www.yso.fi/onto/yso/p8090> .
    ?sub skos:broader ?ylakasite . }
   ?sub skos:prefLabel ?label .
   FILTER(LANGMATCHES(LANG(?label), "fi"))
    OPTIONAL { 
        ?sub skos:broader ?ylakasite .
        ?ylakasite skos:prefLabel ?ylalabel .
   FILTER(LANGMATCHES(LANG(?ylalabel), "fi"))
  }
  }
GROUP BY ?label ?ylakasitteet
LIMIT 10000



Eri kieliversioiden esittäminen rinnakkain taulukkona

Tällä haulla saa kätevästi esitettyä samalla rivillä taulukossa YSO:n käsitteitä suomeksi, ruotsiksi ja englanniksi. Hakua on kätevä muokata rivillä 8 olevan säännöllisen lausekkeen avulla. 

Code Block
PREFIX rdf: 

...

<http://www.w3.org/1999/02/22-rdf-syntax-

...

ns#>
PREFIX rdfs: 

...

<http://www.w3.org/2000/01/rdf-

...

schema#>
PREFIX skos: 

...

<http://www.w3.org/2004/02/skos/

...

core#>
SELECT * WHERE {

...


  ?concept skos:prefLabel ?plfi .

...


  FILTER regex(str(?concept), "

...

^http://www.yso.fi/onto/yso/") .

...


  FILTER(lang(?plfi) = "fi")

...


  FILTER (regex(?plfi, "^[Aa]"))

...


  OPTIONAL{

...


    ?concept skos:prefLabel ?plen . FILTER(lang(?plen) = "en")

...


  }

...


  OPTIONAL{

...


    ?concept skos:prefLabel ?plsv . FILTER(lang(?plsv) = "sv")

...


  }

...


}

...


LIMIT 100






Wikidataan liittyviä hakuja

Hae Wikidatasta YSO-ID propertyllä merkityt käsitteet

Code Block
#tee tämä

...

 haku Wikdatassa: https://query.wikidata.org/

SELECT *

...


WHERE {

...


SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

...


OPTIONAL { ?item wdt:P2347 ?YSO_tunniste. }

...


?item rdfs:label ?label_se filter (lang(?label_se) = "se").

...


?item rdfs:label ?label_fi filter (lang(?label_fi) = "fi").

...


# ?item rdfs:label ?label_sv filter (lang(?label_sv) = "sv").

...


# ?item rdfs:label ?label_en filter (lang(?label_en) = "en").

...


}

...


LIMIT 10

Hae

...

Wikidatasta

...

kaikki

...

käsitteen

...

Q

...

alakäsitteet

...

Code Block
# LIST All subclasses of Q as $s 

...


# https://query.wikidata.org/

...


PREFIX wd: 

...

<http://www.wikidata.org/entity/>

...


PREFIX wdt: 

...

<http://www.wikidata.org/prop/direct/>

...


PREFIX rdfs: 

...

<http://www.w3.org/2000/01/rdf-

...

schema#>

SELECT  ?s ?fi_desc ?sv_desc ?en_desc $sLabel

...


WHERE {

...


?s wdt:P279+ wd:Q1318295 .  # vaihda tähän käsite, jonka alakäsitteitä haluat listata

...


OPTIONAL { 

...


  { ?s rdfs:label ?en_desc filter (lang(?en_desc) = "en"). }

...


  { ?s rdfs:label ?fi_desc filter (lang(?fi_desc) = "fi"). }

...


  { ?s rdfs:label ?sv_desc filter (lang(?sv_desc) = "sv"). }

...


}

...


SERVICE wikibase:label { bd:serviceParam wikibase:language "en","fi","sv". } # Helps get the label in your language, if not, then en language

...


}

...


limit 100

Hae Wikidatasta kaikki MML-paikkatyypit

Code Block
languagesql
# Tee tämä haku Wikidatassa: https://w.wiki/6aT4
SELECT  ?paikkatyyppi ?paikkatyyppiLabel ?Paikannimirekisterin_paikkatyyppitunniste   WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  
  ?paikkatyyppi wdt:P31 wd:Q106589826.
  OPTIONAL { ?paikkatyyppi wdt:P9230 ?Paikannimirekisterin_paikkatyyppitunniste. }
}


YKL:ään liittyviä hakuja

Etsi kaikkien YKL-luokkien URI, prefLabel ja skos:scopeNote

...