NOSAD-POC: Difference between revisions

From oswald
Jump to navigation Jump to search
Line 109: Line 109:
</sparql>
</sparql>


==== Talare som finns på Dartaportalens forum ====
<sparql tryit="1">
#title: Talare NOSAD som finns på Dataportalen
PREFIX od: <https://oswald.wikibase.cloud/entity/>
PREFIX odt: <https://oswald.wikibase.cloud/prop/direct/>
SELECT distinct ?spkr  ?spkrLabel ?Dataportalen ?Linkedin ?GITHUB
WHERE {
  ?pres odt:P12 od:Q157 . # a Presentation
  ?pres odt:P13 ?spkr .
  ?spkr odt:P31 ?DPid.
  OPTIONAL {?spkr odt:P27 ?Lid}
  OPTIONAL {?spkr odt:P32 ?Gid}
 
  BIND(URI(CONCAT("https://community.dataportal.se/user/",?DPid)) as ?Dataportalen)
  BIND(URI(CONCAT("https://www.linkedin.com/in/",?Lid)) as ?Linkedin)
  BIND(URI(CONCAT("https://github.com/",?Gid)) as ?GITHUB)
SERVICE wikibase:label {
    bd:serviceParam wikibase:language "sv,en".
  }
}
ORDER BY ?spkrLabel
</sparql>
[[category:SPARQL]]
[[category:SPARQL]]

Revision as of 21:30, 4 December 2022

POC using NOSAD metadata in a Wikibase.cloud instance

NOSAD a "Network Open Source and Data" for swedish public organisations

NOSAD Wikibase Queries

Misc

SPARQL Frågor

Lista föreläsningar i omvänd tidsordning med ID, titel, videolänk osv.

#title: Presentations latest first with ID, event, title, start time, video link etc.
# https://beyond-notability.wikibase.cloud/wiki/Project:SPARQL/examples
PREFIX wd: <https://oswald.wikibase.cloud/entity/>
PREFIX wds: <https://oswald.wikibase.cloud/entity/statement/>
PREFIX wdv: <https://oswald.wikibase.cloud/value/>
PREFIX wdt: <https://oswald.wikibase.cloud/prop/direct/>
PREFIX p: <https://oswald.wikibase.cloud/prop/>
PREFIX ps: <https://oswald.wikibase.cloud/prop/statement/>
PREFIX pq: <https://oswald.wikibase.cloud/prop/qualifier/>
# 2022-w42-7
SELECT
?dt ?sess ?sessLabel ?agenda ?start
?pres ?presLabel ?org ?orgLabel ?spkr ?spkrLabel
?vurl_t ?yturl_t
WHERE {
  ?pres wdt:P12 wd:Q157 . # a Presentation
  OPTIONAL{?pres wdt:P14 ?org .}
  OPTIONAL{?pres wdt:P20 ?sess .}
  OPTIONAL{?sess wdt:P22 ?dt .}
  OPTIONAL{?pres wdt:P23 ?start .}
  OPTIONAL{?sess wdt:P16 ?vurl .}
  OPTIONAL{?sess wdt:P21 ?ytid .}
  OPTIONAL{?pres wdt:P13 ?spkr .}
  OPTIONAL{?sess wdt:P17 ?agenda .}
  # BIND expressions referring to variables need to be outside OPTIONAL for some reason?
  BIND(COALESCE(?start, 0) AS ?t0).
  BIND(IRI(CONCAT(STR(?vurl), IF(?t0 > 0, CONCAT("#t=", STR(?t0)), ""))) AS ?vurl_t) .
  BIND(IRI(CONCAT("https://www.youtube.com/watch?v=", ?ytid, IF(?t0 > 0, CONCAT("#t=", STR(?t0)), ""))) AS ?yturl_t) .

  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "sv,no,en-gb,en".
  }
}
ORDER BY DESC(?dt) ?sessLabel (!BOUND(?start)) ?start ?presLabel

Try it!


Hämta alla organisationer i Oswald som har koppling WD och hämta från WD med SPARQL federation deras Organisationsnummer, visa det på Quickstatement format

#title:  org hos NOSAD där WD har Organisationsnr P6460 info som saknas lokalt P37 som QuickStatement - SPARQL Federation
PREFIX od: <https://oswald.wikibase.cloud/entity/>
PREFIX odt: <https://oswald.wikibase.cloud/prop/direct/>

SELECT DISTINCT ?Oswald ("P37" AS ?P) ?orgnr WHERE {

  VALUES ?Orgobj {
    od:Q76
  }
  ?org odt:P12 ?Orgobj.
  ?org odt:P2 ?WDs.
  BIND(URI(REPLACE(STR(?WDs), "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) AS ?WD)
  SERVICE <https://query.wikidata.org/sparql> {
    ?WD wdt:P6460 ?wdorg.
    BIND(CONCAT("\"", str(?wdorg), "\"") AS ?orgnr)
  }
  BIND(REPLACE(STR(?org), "https://oswald.wikibase.cloud/entity/", "") AS ?Oswald)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
}
ORDER BY (?spkrOswaldLabel)

Try it!

SPARQL Hämta datalistor motsvarande nosad.se

Test för jämförelse av innehåll som skiljer sig åt, och som exempel för datadrivet innehåll.

nosad.se Organisationer "Inspelade NOSAD-event per organisation"

#title: Motsv. https://nosad.se/organisationer/ "Inspelade NOSAD-event per organisation"
PREFIX od: <https://oswald.wikibase.cloud/entity/>
PREFIX odt: <https://oswald.wikibase.cloud/prop/direct/>

SELECT ?pres ?presLabel ?orgLabel ?vurl ?ytid WHERE {
  ?pres odt:P12 od:Q157. # instance of presentation
  ?pres odt:P14 ?org.
  ?pres odt:P20 ?sess.
  OPTIONAL {?sess odt:P16 ?vurl.}
  OPTIONAL {?sess odt:P21 ?ytid.}

  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "sv,no,en".
  }
}
ORDER BY (lcase(?orgLabel))

Try it!


nosad.se Workshops

#title: Motsv. https://nosad.se/workshops/
PREFIX od: <https://oswald.wikibase.cloud/entity/>
PREFIX odt: <https://oswald.wikibase.cloud/prop/direct/>

SELECT ?event ?eventLabel ?date ?agenda_url ?vurl ?ytid WHERE {
  ?event odt:P12 od:Q162. # instance of session
  OPTIONAL {?event odt:P17 ?agenda_url.}
  OPTIONAL {?event odt:P16 ?vurl.}
  OPTIONAL {?event odt:P21 ?ytid.}
  OPTIONAL {?event odt:P22 ?date.}

  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "sv,no,en".
  }
}
ORDER BY DESC(?date)

Try it!


Talare som finns på Dartaportalens forum

#title: Talare NOSAD som finns på Dataportalen
PREFIX od: <https://oswald.wikibase.cloud/entity/>
PREFIX odt: <https://oswald.wikibase.cloud/prop/direct/>
SELECT distinct ?spkr  ?spkrLabel ?Dataportalen ?Linkedin ?GITHUB
WHERE {
  ?pres odt:P12 od:Q157 . # a Presentation
  ?pres odt:P13 ?spkr .
  ?spkr odt:P31 ?DPid.
  OPTIONAL {?spkr odt:P27 ?Lid}
  OPTIONAL {?spkr odt:P32 ?Gid}
  
  BIND(URI(CONCAT("https://community.dataportal.se/user/",?DPid)) as ?Dataportalen)
  BIND(URI(CONCAT("https://www.linkedin.com/in/",?Lid)) as ?Linkedin)
  BIND(URI(CONCAT("https://github.com/",?Gid)) as ?GITHUB)
 SERVICE wikibase:label {
    bd:serviceParam wikibase:language "sv,en".
  }
}
ORDER BY ?spkrLabel

Try it!