├── README.md ├── bin ├── agrovoc.config ├── allars.config ├── jel.config ├── jel.sesame.config ├── load_versions.sh ├── stw.config ├── swdskos.config ├── thesoz.config ├── ysa.config └── yso.config ├── rdfa ├── README.md └── stw │ ├── README.md │ ├── styles │ └── stw.css │ ├── version_8.12_about.html │ ├── version_8.12_about.ttl │ ├── version_about.html │ └── version_about.ttl ├── skos-history.ttl └── sparql ├── README.md ├── _template.rq ├── added_concepts.rq ├── added_concepts_with_top_concepts.rq ├── changed_notations.rq ├── concept_deltas.rq ├── concept_history.rq ├── count_added_concepts.rq ├── count_added_labels.rq ├── count_deleted_concepts.rq ├── count_deleted_labels.rq ├── count_deprecated_concepts.rq ├── deleted_concepts.rq ├── deprecated_concepts.rq ├── jel └── README.md ├── labels_moved_to_added_concepts.rq ├── service_graph.rq ├── stw ├── README.md ├── _template.rq ├── added_broader.rq ├── added_by_category_3levels.rq ├── added_concepts_by_category.rq ├── added_labels.rq ├── added_narrower.rq ├── changed_notations_thsys.rq ├── changed_preferred_labels.rq ├── count_added_concepts.rq ├── count_added_concepts_by_category.rq ├── count_added_concepts_by_category_all.rq ├── count_added_concepts_by_top.rq ├── count_added_labels.rq ├── count_concepts.rq ├── count_deleted_labels.rq ├── count_deprecated_concepts.rq ├── count_deprecated_concepts_by_category.rq ├── count_deprecated_concepts_by_top.rq ├── count_total_concepts_by_category.rq ├── count_total_concepts_by_top.rq ├── deleted_labels.rq ├── deprecated_concepts_all.rq ├── deprecated_concepts_by_category.rq ├── merged_partially.rq ├── moved_categories_subthes.rq └── moved_labels.rq ├── swdskos ├── README.md └── added_concepts_by_category.rq ├── version_graph.rq └── version_overview.rq /README.md: -------------------------------------------------------------------------------- 1 | skos-history 2 | ============ 3 | 4 | "What's new?" and "What has changed?" are common user questions when a new version of a SKOS vocabulary is published. 5 | 6 | This project tries to take advantage of the regular structure of SKOS files to make these questions answerable for both non-geeky humans and machines. To this end, an ontology/application profile, a set of processing practices and supporting code are developed. 7 | 8 | The use cases to be covered are discussed in [List of Use Cases](https://github.com/jneubert/skos-history/wiki/List-of-Use-Cases), the [List of Change Categories](https://github.com/jneubert/skos-history/wiki/List-of-Change-Categories) and in the [issue queue](https://github.com/jneubert/skos-history/issues?state=open). 9 | 10 | [Versions and Deltas as Named Graphs](https://github.com/jneubert/skos-history/wiki/Versions-and-Deltas-as-Named-Graphs) are introduced as an approach to provide the infrastructure to these ends. [SPARQL queries](https://github.com/jneubert/skos-history/tree/master/sparql) can be applied to an example version store created according to this approach, and can be modified for own explorations. A [tutorial](https://github.com/jneubert/skos-history/wiki/Tutorial) describes how to apply this approach to arbitrary SKOS vocabularies, using the code provided here. 11 | 12 | The [skos-history ontology](https://raw.github.com/jneubert/skos-history/main/skos-history.ttl) is meant to be used in combination with the [dataset versioning ontology](https://raw.githubusercontent.com/JohanDS/Dataset-versioning--for-KOS-data-sets-/master/DataSetVersioning.owl) - both being work in progress. 13 | 14 | See also the [Ontologies, Thesauri, Vocabularies](https://github.com/jneubert/skos-history/wiki/Ontologies-Thesauri-Vocabularies) and the [Resources](https://github.com/jneubert/skos-history/wiki/Resources) sections. 15 | 16 | 17 | ### Contributing 18 | 19 | Contributions are very much appreciated - be it in the form of suggestions or bug reports in the [issue queue](https://github.com/jneubert/skos-history/issues), or as patches or pull requests for improved or additional queries or script code. This in particular includes extensions to cover the specifics of not yet well-supported SKOS vocabularies. 20 | 21 | -------------------------------------------------------------------------------- /bin/agrovoc.config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATASET=agrovoc 4 | BASEDIR=/tmp/agrovoc_tmp 5 | FILENAME=core.nt 6 | VERSIONS=(2013-12-17 2014-07-23 2015-03-24) 7 | SCHEMEURI='http://aims.fao.org/aos/agrovoc' 8 | 9 | # read-write endpoint 10 | ENDPOINT=http://localhost:3030/${DATASET}v 11 | PUT_URI=$ENDPOINT/data 12 | UPDATE_URI=$ENDPOINT/update 13 | 14 | # public read-only endpoint 15 | QUERY_URI=http://zbw.eu/beta/${DATASET}v/sparql/query 16 | -------------------------------------------------------------------------------- /bin/allars.config: -------------------------------------------------------------------------------- 1 | DATASET=allars 2 | BASEDIR=/data/skos-history-data/allars/ 3 | FILENAME=allars-skos.ttl 4 | VERSIONS=($(cd $BASEDIR && find * -maxdepth 0 -type d)) 5 | SCHEMEURI='http://www.yso.fi/onto/allars/' 6 | 7 | ENDPOINT=http://sparql.dev.finto.fi/skos-history 8 | PUT_URI=$ENDPOINT/data 9 | UPDATE_URI=$ENDPOINT/update 10 | QUERY_URI=$ENDPOINT/sparql 11 | -------------------------------------------------------------------------------- /bin/jel.config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATASET=jel 4 | SCHEMEURI="http://zbw.eu/beta/external_identifiers/jel" 5 | 6 | # files are loaded from $BASEDIR/$VERSIONS/$FILENAME 7 | # (our jel files 2010-09 and 2011-11 seem to have messed up version 8 | # information, therefore skipped here) 9 | VERSIONS=(2008-10 2009-02 20120320 20130621 20141202 20170126 20210225) 10 | BASEDIR=/opt/thes/var/jel 11 | FILENAME=rdf/jel.ttl 12 | 13 | # private read/write fuseki2 endpoints 14 | PUT_URI=http://localhost:3030/jelv/data 15 | UPDATE_URI=http://localhost:3030/jelv/update 16 | 17 | # public read-only fuseki2 endpoint 18 | QUERY_URI=http://zbw.eu/beta/jelv/sparql/query 19 | -------------------------------------------------------------------------------- /bin/jel.sesame.config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATASET=jel 4 | SCHEMEURI="http://zbw.eu/beta/external_identifiers/jel" 5 | 6 | # files are loaded from $BASEDIR/$VERSIONS/$FILENAME 7 | VERSIONS=(20120320 20130621) 8 | BASEDIR=/opt/thes/var/jel 9 | FILENAME=rdf/jel.ttl 10 | 11 | # private read/write sesame endpoints 12 | PUT_URI=http://localhost:8080/openrdf-sesame/repositories/jelv/rdf-graphs/service 13 | UPDATE_URI=http://localhost:8080/openrdf-sesame/repositories/jelv/statements 14 | 15 | # read-only sesame endpoint 16 | QUERY_URI=http://localhost:8080/openrdf-sesame/repositories/jelv 17 | -------------------------------------------------------------------------------- /bin/load_versions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # nbt, 1.9.2013 3 | 4 | # load a series of version and delta graphs into a SPARQL 1.1 RDF dataset 5 | 6 | 7 | ## Help text 8 | usage () 9 | { 10 | echo "usage: load_versions.sh [[-f file ] | [-h]]" 11 | echo "examples: load_versions.sh -f yso.config" 12 | echo "NOTE: the directory of the file needs to be in PATH or the path should be explicit" 13 | } 14 | 15 | ## Read configuration 16 | 17 | # demands 1 or 2 command-line arguments 18 | if [ $# -lt 1 -o $# -gt 2 ] 19 | then 20 | usage 21 | exit 1 22 | fi 23 | 24 | # Handling the command line arguments 25 | # Get the configure file path 26 | while [ "$1" != "" ]; do 27 | case $1 in 28 | -f | --file ) shift 29 | configfile=$1 30 | ;; 31 | -h | --help ) usage 32 | exit 33 | ;; 34 | * ) usage 35 | exit 1 36 | esac 37 | shift 38 | done 39 | 40 | # reading in the stored variablesb from the configuration file 41 | . $configfile 42 | 43 | 44 | ####################### 45 | # function definitions 46 | ####################### 47 | 48 | sparql_put() 49 | { 50 | local graph=$1 51 | local file=$2 52 | if [ ! -f $file ]; then 53 | echo "$file does not exist" 54 | exit 1 55 | fi 56 | curl --silent -X PUT -H "Content-Type: text/turtle" -d @$file $PUT_URI?graph=$graph > /dev/null 57 | local status=$? 58 | if [ $status -ne 0 ]; then 59 | echo "\nPUT for file $file failed with status $status" 60 | exit $status 61 | fi 62 | } 63 | 64 | sparql_update() 65 | { 66 | # suppress output of returned HTML (in case of fuseki) 67 | curl -X POST --silent -d "update=$1" $UPDATE_URI > /dev/null 68 | local status=$? 69 | if [ $status -ne 0 ]; then 70 | echo "\nPOST for update failed with status $status - update was:" 71 | echo "$1\n" 72 | exit $status 73 | fi 74 | } 75 | 76 | load_version () { 77 | 78 | # parameter check 79 | if [ -z "$1" ]; then 80 | echo "function must be called with \$version parameter" 81 | exit 82 | else 83 | version=$1 84 | fi 85 | 86 | # load the version graph 87 | printf "\nLoading version $BASEURI/$version\n" 88 | sparql_put $BASEURI/$version $BASEDIR/$version/$FILENAME 89 | 90 | # add triples to the version graph 91 | # (particularly frbrer is Realization Of) 92 | statement=" 93 | $PREFIXES 94 | insert { 95 | GRAPH <$BASEURI/$version> { 96 | <$BASEURI/$version> <$SCHEMEURI> . 97 | <$SCHEMEURI> dsv:hasVersionRecord <${BASEURI}record/$latest> ; 98 | :hasVersionHistorySet <$BASEURI> . 99 | } 100 | } 101 | where {} 102 | " 103 | sparql_update "$statement" 104 | 105 | # add triples to the version history graph 106 | # (fix invalid string date format for thesoz and for older stw versions) 107 | statement=" 108 | $PREFIXES 109 | insert { 110 | GRAPH <$BASEURI> { 111 | <${BASEURI}record/$version> 112 | a dsv:VersionHistoryRecord ; 113 | dsv:hasVersionHistorySet <${BASEURI}> ; 114 | dsv:isVersionRecordOf <$BASEURI/$version/download/$DATASET.rdf.zip> ; 115 | dsv:isVersionRecordOf <$BASEURI/$version/download/$DATASET.ttl.zip> ; 116 | dsv:isVersionRecordOf <$BASEURI/$version/ng> ; 117 | :usingNamedGraph <$BASEURI/$version/ng> ; 118 | dc:date ?fixedDate ; 119 | dc:identifier ?fixedIdentifier . 120 | <$BASEURI/$version/ng> a sd:NamedGraph ; 121 | sd:name <$BASEURI/$version> . 122 | } 123 | } 124 | where { 125 | GRAPH <$BASEURI/$version> { 126 | # compute identifier (fix missing if necessary) 127 | # stw and recent thesoz version property 128 | OPTIONAL { 129 | <$SCHEMEURI> owl:versionInfo ?identifier 130 | # avoid using SVN-generated version strings in e.g. old YSA versions 131 | FILTER (!CONTAINS(?identifier, '$')) 132 | } . 133 | # old thesoz version prpoperty 134 | OPTIONAL { <$SCHEMEURI> dcterms:hasVersion ?identifier } . 135 | # otherwise, use $version 136 | BIND (coalesce(?identifier, \"$version\") as ?fixedIdentifier) 137 | 138 | # compute date as xsd:date (fix if necessary - 139 | # date values may occur as string, xsd:date or xsd:dateTime; 140 | # strings may take the form of 'yyyy/mm/dd' (thesoz 0.7) or 'yyyy-mm-ddThh:mm:ssZ' 141 | 142 | # stw uses dcterms:issued (string or xsd:date) 143 | OPTIONAL { 144 | <$SCHEMEURI> dcterms:issued ?issued . 145 | } 146 | # thesoz et al. use dcterms:modified (in case of thesoz, plus dcterms:issued for created date) 147 | OPTIONAL { 148 | <$SCHEMEURI> dcterms:modified ?modified . 149 | } 150 | BIND (str(coalesce(?modified, ?issued)) as ?someStr) 151 | BIND (concat(substr(?someStr, 1, 4), '-', substr(?someStr, 6, 2), '-', substr(?someStr, 9, 2)) as ?dateStr) 152 | BIND (strdt(?dateStr, xsd:date) as ?fixedDate) 153 | } 154 | } 155 | " 156 | sparql_update "$statement" 157 | 158 | # special clause for thesauri which have no unique 159 | # version date in the data and are enumerated in $VERSIONS by a valid date 160 | VERSION_DATE_MISSING="agrovoc jel" 161 | if [[ $VERSION_DATE_MISSING =~ (^|[[:space:]])$DATASET($|[[:space:]]) ]] ; then 162 | # delete multiple entries, as provided by agrovoc 163 | statement=" 164 | $PREFIXES 165 | DELETE WHERE { 166 | GRAPH <$BASEURI> { 167 | <${BASEURI}record/$version> dc:date ?x . 168 | } 169 | } 170 | " 171 | sparql_update "$statement" 172 | 173 | # insert triple constructed from version string 174 | statement=" 175 | $PREFIXES 176 | insert { 177 | GRAPH <$BASEURI> { 178 | <${BASEURI}record/$version> dc:date \"$version\"^^xsd:date . 179 | } 180 | } 181 | where {} 182 | " 183 | sparql_update "$statement" 184 | fi 185 | 186 | # complement service description 187 | statement=" 188 | $PREFIXES 189 | insert { 190 | <$SERVICE_DDURI> sd:namedGraph <$BASEURI/$version/ng> . 191 | <$BASEURI/$version/ng> a sd:NamedGraph ; 192 | sd:name <$BASEURI/$version> . 193 | } 194 | where {} 195 | " 196 | sparql_update "$statement" 197 | } 198 | 199 | # create and load a delta and add metadata for it 200 | load_delta () { 201 | 202 | # parameter check 203 | if [ -z "$2" ]; then 204 | echo "function must be called with \$old and \$new parameter" 205 | else 206 | old=$1 207 | new=$2 208 | fi 209 | 210 | delta_uri=$BASEURI/$old/delta/$new 211 | printf "\nCreating the delta $delta_uri\n" 212 | 213 | # add triples to version history graph 214 | statement=" 215 | $PREFIXES 216 | insert { 217 | GRAPH <$BASEURI> { 218 | <${BASEURI}record/$old> :hasDelta <$delta_uri> . 219 | <${BASEURI}record/$new> :hasDelta <$delta_uri> . 220 | <$delta_uri> a :SchemeDelta ; 221 | :deltaFrom <${BASEURI}record/$old> ; 222 | :deltaTo <${BASEURI}record/$new> . 223 | } 224 | } 225 | where {} 226 | " 227 | sparql_update "$statement" 228 | 229 | # load delta 230 | for op in deletions insertions; do 231 | 232 | # make variable with first character uppercased 233 | op_var="$(tr '[:lower:]' '[:upper:]' <<< ${op:0:1})${op:1}" 234 | 235 | # compute the difference between the versions 236 | # and insert into the delta graph 237 | if [ $op == 'deletions' ]; then 238 | minuend=$old 239 | subtrahend=$new 240 | else 241 | minuend=$new 242 | subtrahend=$old 243 | fi 244 | statement=" 245 | $PREFIXES 246 | insert { 247 | GRAPH <$delta_uri/$op> { 248 | ?s ?p ?o 249 | } 250 | } 251 | where { 252 | graph <$BASEURI/$minuend> { 253 | ?s ?p ?o 254 | } 255 | minus { 256 | graph <$BASEURI/$subtrahend> { 257 | ?s ?p ?o 258 | } 259 | } 260 | # filter out blank nodes 261 | filter isIRI(?s) 262 | filter (isIRI(?o) || isLiteral(?o) || isNumeric(?o)) 263 | } 264 | " 265 | sparql_update "$statement" 266 | 267 | statement=" 268 | $PREFIXES 269 | insert { 270 | GRAPH <$BASEURI> { 271 | <$delta_uri> dcterms:hasPart <$delta_uri/$op> . 272 | <$delta_uri/$op> a :SchemeDelta$op_var ; 273 | dcterms:isPartOf <$delta_uri> ; 274 | :usingNamedGraph <$delta_uri/$op/ng> . 275 | <$delta_uri/$op/ng> a sd:NamedGraph ; 276 | sd:name <$delta_uri/$op> . 277 | } 278 | } 279 | where {} 280 | " 281 | sparql_update "$statement" 282 | 283 | # complement service description 284 | statement=" 285 | $PREFIXES 286 | insert { 287 | <$SERVICE_DDURI> sd:namedGraph <$delta_uri/$op/ng> . 288 | <$delta_uri/$op/ng> a sd:NamedGraph ; 289 | sd:name <$delta_uri/$op> . 290 | } 291 | where {} 292 | " 293 | sparql_update "$statement" 294 | 295 | done 296 | } 297 | 298 | ############## 299 | # script body 300 | ############## 301 | 302 | # handle trailing slash in scheme uri 303 | if [ "${SCHEMEURI: -1}" == "/" ]; then 304 | BASEURI=${SCHEMEURI}version 305 | else 306 | BASEURI=$SCHEMEURI/version 307 | fi 308 | SPARQL_DDURI=$BASEURI/sparq-service/dd 309 | 310 | PREFIXES=" 311 | prefix : 312 | prefix dc: 313 | prefix dcterms: 314 | prefix dsv: 315 | prefix owl: 316 | prefix rdf: 317 | prefix rdfs: 318 | prefix sd: 319 | prefix skos: 320 | prefix void: 321 | prefix xhv: 322 | prefix xsd: 323 | " 324 | 325 | # create a SPARQL service description in the default graph 326 | SERVICE_URI=$BASEURI/sparql-service 327 | SERVICE_DDURI=$SERVICE_URI/dd 328 | statement=" 329 | $PREFIXES 330 | insert { 331 | <$SERVICE_URI> a sd:Service; 332 | sd:endpoint <$QUERY_URI>; 333 | sd:defaultDataset <$SERVICE_DDURI> . 334 | <$SERVICE_DDURI> a sd:Dataset; 335 | dcterms:title \"$DATASET Versions SPARQL Service\"; 336 | sd:defaultGraph [ 337 | a sd:Graph; 338 | dcterms:title \"$DATASET Versions SPARQL Service Description\"; 339 | ] . 340 | } 341 | where {} 342 | " 343 | sparql_update "$statement" 344 | 345 | # load latest version to the version history graph 346 | latest=${VERSIONS[${#VERSIONS[@]} - 1]} 347 | echo "" 348 | echo Initializing the version history graph with the current version 349 | statement=" 350 | $PREFIXES 351 | insert { 352 | # Strangely, WITH syntax does not work here!! 353 | graph <$BASEURI> { 354 | <$BASEURI> a dsv:VersionHistorySet ; 355 | :isVersionHistoryOf <$SCHEMEURI> ; 356 | dsv:currentVersionRecord <${BASEURI}record/$latest> ; 357 | void:sparqlEndpoint <$QUERY_URI> ; 358 | :usingNamedGraph <$BASEURI/ng> . 359 | <$BASEURI/ng> a sd:NamedGraph ; 360 | sd:name <$BASEURI> . 361 | } 362 | } 363 | where {} 364 | " 365 | sparql_update "$statement" 366 | 367 | # complement service description 368 | statement=" 369 | $PREFIXES 370 | insert { 371 | <$SERVICE_DDURI> sd:namedGraph <$BASEURI/ng> . 372 | <$BASEURI/ng> a sd:NamedGraph ; 373 | sd:name <$BASEURI> . 374 | } 375 | where {} 376 | " 377 | sparql_update "$statement" 378 | 379 | # iterate over the versions, load them and add metadata to the version graph 380 | for index in ${!VERSIONS[*]} 381 | do 382 | version=${VERSIONS[$index]} 383 | load_version $version 384 | done 385 | 386 | # iterate over the versions, create and load deltas + metadata 387 | # (in a second pass, to avoid triples being overridden by version loading) 388 | for index in ${!VERSIONS[*]} 389 | do 390 | old=${VERSIONS[$index]} 391 | new=${VERSIONS[$index+1]} 392 | latest=${VERSIONS[${#VERSIONS[@]} - 1]} 393 | penultimate=${VERSIONS[${#VERSIONS[@]} - 2]} 394 | 395 | # load delta to the next version 396 | if [ "$old" != "$latest" ]; then 397 | load_delta $old $new 398 | 399 | # load a xhv:prev statement for immediately following versions 400 | statement=" 401 | $PREFIXES 402 | insert { 403 | GRAPH <$BASEURI> { 404 | <${BASEURI}record/$new> xhv:prev <${BASEURI}record/$old> . 405 | } 406 | } 407 | where {} 408 | " 409 | sparql_update "$statement" 410 | fi 411 | 412 | # load delta to the latest version 413 | if [ "$old" != "$penultimate" ] && [ "$old" != "$latest" ]; then 414 | load_delta $old $latest 415 | fi 416 | done 417 | 418 | echo "" 419 | -------------------------------------------------------------------------------- /bin/stw.config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # includes a download of version files 4 | 5 | DATASET=stw 6 | BASEDIR=/var/tmp/stw_versions 7 | FILENAME=rdf/stw.nt 8 | VERSIONS=(8.04 8.06 8.08 8.10 8.12 8.14 9.0 9.02 9.04 9.06 9.08 9.10 9.12 9.14 9.16) 9 | SCHEMEURI='http://zbw.eu/stw' 10 | 11 | # read-write endpoint 12 | ENDPOINT=http://localhost:3030/${DATASET}v 13 | PUT_URI=$ENDPOINT/data 14 | UPDATE_URI=$ENDPOINT/update 15 | 16 | # public read-only endpoint 17 | #QUERY_URI=http://zbw.eu/beta/${DATASET}v/sparql/query 18 | QUERY_URI=http://localhost:3030/${DATASET}v/sparql/query 19 | 20 | # get the data from http://zbw.eu/stw, if it does not exist locally 21 | for index in ${!VERSIONS[*]} 22 | do 23 | version=${VERSIONS[$index]} 24 | dir=$BASEDIR/$version 25 | file=$dir/$FILENAME 26 | if [ ! -f $file ]; then 27 | echo "downloading $download_url" 28 | mkdir -p $dir/rdf 29 | download_file="$dir/rdf/stw.rdf.zip" 30 | # work with unpublished file on dev machine 31 | if [ "`hostname -s`" == "stw-srv-01" ]; then 32 | cp /opt/thes/var/html/stw/version/$version/download/stw.rdf.zip $dir/rdf 33 | else 34 | download_url="http://zbw.eu/stw/versions/$version/download/stw.rdf.zip" 35 | wget -O $download_file $download_url 36 | fi 37 | unzip -d $dir/rdf $download_file 38 | rapper -i guess $dir/rdf/stw.rdf > $file 39 | rm $download_file $dir/rdf/stw.rdf 40 | fi 41 | done 42 | 43 | -------------------------------------------------------------------------------- /bin/swdskos.config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATASET=swdskos 4 | BASEDIR=/opt/thes/var/swdskos 5 | FILENAME=rdf/swdskos.ttl 6 | VERSIONS=(2015-05-13 2015-10-13 2016-02) 7 | SCHEMEURI="http://zbw.eu/beta/swdskos" 8 | 9 | # private read/write endpoints 10 | ENDPOINT=http://localhost:3030/${DATASET}v 11 | PUT_URI=$ENDPOINT/data 12 | UPDATE_URI=$ENDPOINT/update 13 | 14 | # public read-only endpoint 15 | QUERY_URI=http://zbw.eu/beta/${DATASET}v/sparql/query 16 | -------------------------------------------------------------------------------- /bin/thesoz.config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATASET=thesoz 4 | BASEDIR=/opt/thes/var/thesoz 5 | FILENAME=rdf/thesoz.nt 6 | VERSIONS=(0.7 0.86 0.91 0.92 0.93 0.94) 7 | SCHEMEURI='http://lod.gesis.org/thesoz/' 8 | 9 | #!/bin/bash 10 | ENDPOINT=http://localhost:3030/${DATASET}v 11 | PUT_URI=$ENDPOINT/data 12 | UPDATE_URI=$ENDPOINT/update 13 | 14 | # public read-only endpoint 15 | QUERY_URI=http://zbw.eu/beta/${DATASET}v/sparql/query 16 | 17 | -------------------------------------------------------------------------------- /bin/ysa.config: -------------------------------------------------------------------------------- 1 | DATASET=ysa 2 | BASEDIR=/data/skos-history-data/ysa/ 3 | FILENAME=ysa-skos.ttl 4 | VERSIONS=($(cd $BASEDIR && find * -maxdepth 0 -type d)) 5 | SCHEMEURI='http://www.yso.fi/onto/ysa/' 6 | 7 | ENDPOINT=http://sparql.dev.finto.fi/skos-history 8 | PUT_URI=$ENDPOINT/data 9 | UPDATE_URI=$ENDPOINT/update 10 | QUERY_URI=$ENDPOINT/sparql 11 | -------------------------------------------------------------------------------- /bin/yso.config: -------------------------------------------------------------------------------- 1 | DATASET=yso 2 | BASEDIR=/home/sinpessa/tunk/skos-history-yso 3 | FILENAME=yso-skos.ttl 4 | VERSIONS=(20150102 20150128 20150129) 5 | SCHEMEURI='http://www.yso.fi/onto/yso/' 6 | 7 | ENDPOINT=http://sparql.dev.finto.fi/skos-history 8 | PUT_URI=$ENDPOINT/data 9 | UPDATE_URI=$ENDPOINT/update 10 | QUERY_URI=$ENDPOINT/sparql 11 | -------------------------------------------------------------------------------- /rdfa/README.md: -------------------------------------------------------------------------------- 1 | Dataset versioning information may be published as RDFa, as in the dataset-specific examples here. 2 | -------------------------------------------------------------------------------- /rdfa/stw/README.md: -------------------------------------------------------------------------------- 1 | STW Thesaurus for Economics 2 | --------------------------- 3 | 4 | The proposed [Dataset versioning 5 | ontology](http://purl.org/iso25964/DataSet/Versioning#) 6 | ([github](https://github.com/JohanDS/Dataset-versioning--for-KOS-data-sets-)) 7 | and skos-history approach is implemented in the HTML/RDFa pages of the STW. 8 | 9 | The page for the version history set is at http://zbw.eu/stw/version. The 10 | homepage for current STW version (http://zbw.eu/stw/version/latest) links to 11 | that version history set and to the particular version history record. Please 12 | use the "RDF/XML" or "RDF/Turtle" links on the pages to look at the actual 13 | triples. 14 | 15 | The files in this directory are an early experimental implementation, outdated now. 16 | -------------------------------------------------------------------------------- /rdfa/stw/styles/stw.css: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009, Yahoo! Inc. All rights reserved. 3 | Code licensed under the BSD License: 4 | http://developer.yahoo.net/yui/license.txt 5 | version: 2.7.0 6 | */ 7 | /** 8 | * YUI Base 9 | * @module base 10 | * @namespace yui- 11 | * @requires reset, fonts 12 | */ 13 | 14 | /* 15 | body { 16 | /* For breathing room between content and viewport. 17 | margin:10px; 18 | } 19 | */ 20 | 21 | h1 { 22 | /* 18px via YUI Fonts CSS foundation. */ 23 | font-size: 138.5%; 24 | } 25 | 26 | h2 { 27 | /* 16px via YUI Fonts CSS foundation. */ 28 | font-size: 123.1%; 29 | } 30 | 31 | h3 { 32 | /* 14px via YUI Fonts CSS foundation. */ 33 | font-size: 108%; 34 | } 35 | 36 | h1,h2,h3 { 37 | /* Top & bottom margin based on font size. */ 38 | margin: 1em 0; 39 | } 40 | 41 | h1,h2,h3,h4,h5,h6,strong,dt { 42 | /* Bringing boldness back to headers and the strong element. */ 43 | font-weight: bold; 44 | } 45 | optgroup { 46 | font-weight:normal; 47 | } 48 | 49 | abbr,acronym { 50 | /* Indicating to users that more info is available. */ 51 | border-bottom: 1px dotted #000; 52 | cursor: help; 53 | } 54 | 55 | em { 56 | /* Bringing italics back to the em element. */ 57 | font-style: italic; 58 | } 59 | 60 | del { 61 | /* Striking deleted phrases. */ 62 | text-decoration: line-through; 63 | } 64 | 65 | blockquote,ul,ol,dl { 66 | /* Giving blockquotes and lists room to breath. */ 67 | margin: 1em; 68 | } 69 | 70 | ol,ul,dl { 71 | /* Bringing lists on to the page with breathing room. */ 72 | margin-left: 2em; 73 | } 74 | 75 | ol li { 76 | /* Giving OL's LIs generated numbers. */ 77 | list-style: decimal outside; 78 | } 79 | 80 | /* 81 | ul li { 82 | /* Giving UL's LIs generated disc markers. 83 | list-style: disc outside; 84 | } 85 | */ 86 | 87 | dl dd { 88 | /* Giving UL's LIs generated numbers. */ 89 | margin-left: 1em; 90 | } 91 | 92 | th,td { 93 | /* Borders and padding to make the table readable. */ 94 | border: 1px solid #000; 95 | padding: .5em; 96 | } 97 | 98 | th { 99 | /* Distinguishing table headers from data cells. */ 100 | font-weight: bold; 101 | text-align: center; 102 | } 103 | 104 | caption { 105 | /* Coordinated margin to match cell's padding. */ 106 | margin-bottom: .5em; 107 | /* Centered so it doesn't blend in to other content. */ 108 | text-align: center; 109 | } 110 | 111 | sup { 112 | /* to preserve line-height and selector appearance */ 113 | vertical-align: super; 114 | } 115 | 116 | sub { 117 | /* to preserve line-height and selector appearance */ 118 | vertical-align: sub; 119 | } 120 | 121 | p, 122 | fieldset, 123 | table, 124 | pre { 125 | /* So things don't run into each other. */ 126 | margin-bottom: 1em; 127 | } 128 | /* Opera requires 1px of passing to render with contemporary native chrome */ 129 | button, 130 | input[type="checkbox"], 131 | input[type="radio"], 132 | input[type="reset"], 133 | input[type="submit"] { 134 | padding:1px; 135 | } 136 | 137 | /* ########################### */ 138 | 139 | #doc { 140 | float: left; 141 | font-family: verdana,arial,helvetica,clean,sans-serif; 142 | } 143 | 144 | h4 { 145 | margin-bottom: 0.5em; 146 | } 147 | 148 | a { 149 | color: #005d95; 150 | text-decoration: none; 151 | } 152 | 153 | a:hover { 154 | color: #005d95; 155 | text-decoration: underline; 156 | } 157 | 158 | 159 | ul li { 160 | list-style-position: outside; 161 | list-style-image: url(../images/dot_5x5_blaugrau.gif); 162 | } 163 | 164 | tt, pre { 165 | font-size: 85%; 166 | } 167 | 168 | #hd { 169 | height: 101px; 170 | margin-bottom: 20px; 171 | } 172 | 173 | .zbw-blue-line { 174 | width: 100%; 175 | height: 10px; 176 | } 177 | 178 | #lang-choise { 179 | margin-top: 26px; 180 | margin-right: 1em; 181 | margin-bottom: 12px; 182 | text-align: right; 183 | font-size: 85%; 184 | } 185 | 186 | #suggest_form { 187 | margin-bottom:1em; 188 | margin-left: 4.5em; 189 | margin-right: 1em; 190 | } 191 | 192 | #suggest_ac { 193 | /* width:25em; /* set width here or else widget will expand to fit its container */ 194 | } 195 | 196 | #bd { 197 | margin-bottom: 1em; 198 | background-repeat: no-repeat; 199 | background-position: 0px 0px; 200 | padding-top: 0.5em; 201 | padding-bottom: 1em; 202 | } 203 | 204 | /* more indent */ 205 | #bd #yui-main .yui-b .yui-g { 206 | padding-left: 1em; 207 | padding-right: 1.5em; 208 | } 209 | 210 | #menu { 211 | margin-bottom: 2em; 212 | padding-top: 1em; 213 | padding-left: 34px; 214 | font-size: 85%; 215 | } 216 | 217 | #menu ul { 218 | margin-left: 0; 219 | } 220 | 221 | #menu ul li { 222 | list-style: none; 223 | } 224 | 225 | /* padding-left for optical alignment of the entry text 226 | with the 34px left border of www.zbw.eu */ 227 | #thsys_tree { 228 | font-size: 85%; 229 | margin-right: 1em; 230 | padding-left: 15px; 231 | padding-right: 0.5em; 232 | } 233 | 234 | /* rollover effect for treeview */ 235 | .ygtvlabel:hover { 236 | text-decoration:underline; 237 | } 238 | 239 | /* TODO 240 | no rollover for sprites in treeview 241 | 242 | this doesn't work!! 243 | */ 244 | .ygtvcell { 245 | text-decoration:none !important; 246 | } 247 | 248 | #ft { 249 | margin-left: 34px; 250 | font-size: 85%; 251 | } 252 | 253 | #license_left { 254 | float: left; 255 | width: 190px; 256 | } 257 | 258 | .note_small { 259 | font-size: 77%; 260 | } 261 | 262 | .inline_icon { 263 | border: 0px; 264 | height: 1em; 265 | vertical-align: bottom; 266 | } 267 | 268 | /* temporary, for adapting to size of new econbiz logo */ 269 | .inline_icon2 { 270 | border: 0px; 271 | height: 0.88em; 272 | vertical-align: bottom; 273 | } 274 | 275 | .mapping_link_table { 276 | margin-left: 0.5em; 277 | } 278 | 279 | table.mapping_link_table td { 280 | border: 0px; 281 | padding: 0em; 282 | padding-left:0.5em; 283 | vertical-align: top; 284 | } 285 | 286 | table.mapping_description_table td { 287 | border: 0px; 288 | padding: 0.3em 0.5em 0.3em 0em; 289 | vertical-align: top; 290 | } 291 | 292 | table.statistics_table { 293 | margin-bottom: 0em; 294 | } 295 | 296 | table.statistics_table td { 297 | border: 0px; 298 | padding: 0em; 299 | padding-right: 0.5em; 300 | vertical-align: top; 301 | } 302 | 303 | /* necessary for YUI history functions */ 304 | #yui-history-iframe { 305 | position:absolute; 306 | top:0; left:0; 307 | width:1px; height:1px; 308 | visibility:hidden; 309 | } 310 | 311 | #saved_descriptors { 312 | font-size:85%; 313 | visibility:hidden; 314 | } 315 | -------------------------------------------------------------------------------- /rdfa/stw/version_8.12_about.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 23 | 24 | 25 | 26 | 27 | STW Thesaurus for Economics: Home 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |
57 |
58 |
59 |
60 | Logo: ZBW 61 |
62 |
63 | 64 |
65 | 66 | 67 | RDF/XML   68 | RDF/Turtle   69 | 70 | 72 | Deutsch 73 | 74 | 75 |
76 | 77 |
78 |
79 | 80 |
81 |
82 | 83 |
84 | 85 |
86 |
87 | 88 | 89 | 90 |
91 |
92 |
93 | 94 | 95 | 96 |

STW Thesaurus for Economics

97 | 98 |
99 | 100 | 101 |
102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 |

Version 8.12 114 | (Changes)

116 | 117 | 124 | 125 |

Subthesauri

126 | 127 | 158 | 159 | 160 | 162 | 163 | 167 | 168 | 169 |
170 | 171 |
172 | 173 | 174 | 175 |
176 | 177 | 178 |

The STW Thesaurus for Economics might be helpful while searching ZBW’s economics portal EconBiz and the ECONIS catalogue on economic issues (simply via 180 | Publications about 'Thesaurus' in EconBiz 182 | 183 | or 185 | Publications about 'Thesaurus' in ECONIS 187 | 188 | icon).

189 | 190 |

The thesaurus provides vocabulary on any economic subject: more than 6,000 standardized subject headings and about 19,000 entry terms to support individual keywords. You can also find technical terms used in law, sociology, or politics, and geographic names. When selecting terms from this vocabulary, you are sure to get results matching your search query.

191 | 192 |

The information on the web pages is also embedded as data (RDFa) in order to support multiple re-use in the economics and business communities and within the semantic web.

193 | 194 | 195 | 196 |
197 |
198 | 199 |
200 | 201 | 227 | 228 |
229 | 230 |
231 |
232 | 233 | 234 |
235 |

236 | 237 | STW Thesaurus for Economics 238 | (v 8.12, 239 | 2013-10-30) 240 |  ▪  241 | 242 | Suggestions and comments to the 243 | thesaurus team 244 | 245 | 246 |
247 | 248 | ZBW - Leibniz Information Centre for Economics - 249 | Imprint 250 | 251 |

252 | 253 |
254 |
255 | 256 | 258 | Valid XHTML + RDFa 261 | 262 | 275 | 276 | 277 | 279 | Creative Commons License (by-nc-sa) 281 | 282 |
283 | 284 |
285 | 286 | 287 | The STW Thesaurus for Economics is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Germany License. Permissions beyond the scope of this license are available at ZBW. 288 | 289 |
290 | 291 |
292 |
293 | 294 |
295 | 296 | 297 | 298 | 299 | 300 | 301 | -------------------------------------------------------------------------------- /rdfa/stw/version_8.12_about.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix : . 3 | @prefix cc: . 4 | @prefix dc: . 5 | @prefix dcterms: . 6 | @prefix dsv: 7 | @prefix foaf: . 8 | @prefix gbv: . 9 | @prefix owl: . 10 | @prefix rdfs: . 11 | @prefix skos: . 12 | @prefix stw: . 13 | @prefix void: . 14 | @prefix waiver: . 15 | @prefix xsd: . 16 | @prefix zbwext: . 17 | 18 | 19 | dcterms:isPartOf ; 20 | , , ; 21 | , , . 22 | 23 | 24 | cc:attributionName "ZBW - Leibniz Information Centre for Economics"@en ; 25 | cc:attributionURL ; 26 | cc:license ; 27 | cc:morePermissions "http://www.zbw.eu/e_imprint.htm"@en ; 28 | dc:creator "German National Library of Economics (Kiel) / Hamburgisches Welt-Wirtschaft-Archiv (Hamburg) / ifo Institute (Munich) / GBI-Genios German Business Information (Munich) (for the 1995-1997 built und publicly funded german version of the STW)"@en, "ZBW - Leibniz Information Centre for Economics (for the current german-english version of the STW)"@en ; 29 | dc:publisher "ZBW - Leibniz Information Centre for Economics"@en ; 30 | dcterms:hasVersion ; 31 | dcterms:issued "2013-10-30"^^xsd:date ; 32 | dcterms:title "STW Thesaurus for Economics"@en ; 33 | a skos:ConceptScheme ; 34 | rdfs:isDefinedBy stw:about ; 35 | owl:versionInfo "8.12"^^xsd:string ; 36 | skos:hasTopConcept , , , , , , ; 37 | skos:prefLabel "STW Thesaurus for Economics"@en ; 38 | dsv:hasVersionHistoryRecord . 39 | 40 | 41 | dcterms:isVersionOf . 42 | 43 | 44 | dc:date "2013-10-30"^^xsd:date ; 45 | dc:identifier "8.12"^^xsd:string ; 46 | a dsv:VersionHistoryRecord ; 47 | dsv:hasVersionHistorySet stw:version . 48 | 49 | -------------------------------------------------------------------------------- /rdfa/stw/version_about.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 24 | 25 | 26 | 27 | 28 | STW Thesaurus for Economics: Versions 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |
58 |
59 |
60 |
61 | Logo: ZBW 62 |
63 |
64 | 65 |
66 | 67 | 68 | RDF/XML   69 | RDF/Turtle   70 | 71 | 73 | Deutsch 74 | 75 | 76 |
77 | 78 |
79 |
80 | 81 |
82 |
83 | 84 |
85 | 86 |
87 |
88 | 89 | 90 |
91 |
92 |
93 | 94 |
95 | 96 |

STW Thesaurus for Economics

97 |

Versions

98 | 99 | 100 | 101 | 102 |

Prior versions of the STW are provided here for reference 103 | (Changes).

104 |

Published versions have even version numbers. Odd version numbers 105 | are reserved for internal purposes.

106 | 107 |

Current version is 8.12.

108 | 109 | 110 | 111 |

All published versions:

112 | 113 | 178 | 179 | 180 | 181 | 182 |

Please use the 183 | language- and version-independent URIs to link to the concepts 184 | (eg. http://zbw.eu/stw/descriptor/19664-4 instead of 185 | http://zbw.eu/stw/versions/latest/descriptor/19664-4/about.en.html).

186 | 187 | 188 |
189 | 190 |
191 |
192 | 193 | 194 |
195 | 202 |
203 | 204 | 205 |
206 | 207 |
208 |

209 | 210 | STW Thesaurus for Economics 211 | (v 8.12, 212 | 2013-10-30) 213 |  ▪  214 | 215 | Suggestions and comments to the 216 | thesaurus team 217 | 218 | 219 |
220 | 221 | ZBW - Leibniz Information Centre for Economics - 222 | Imprint 223 | 224 |

225 | 226 |
227 |
228 | 229 | 231 | Valid XHTML + RDFa 234 | 235 | 248 | 249 | 250 | 252 | Creative Commons License (by-nc-sa) 254 | 255 |
256 | 257 |
258 | 259 | 260 | The STW Thesaurus for Economics is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Germany License. Permissions beyond the scope of this license are available at ZBW. 261 | 262 |
263 | 264 |
265 |
266 | 267 |
268 | 269 | 270 | 271 | 272 | 273 | -------------------------------------------------------------------------------- /rdfa/stw/version_about.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix : . 3 | @prefix cc: . 4 | @prefix dc: . 5 | @prefix dcterms: . 6 | @prefix dsv: 7 | @prefix foaf: . 8 | @prefix gbv: . 9 | @prefix owl: . 10 | @prefix rdfs: . 11 | @prefix skos: . 12 | @prefix stw: . 13 | @prefix void: . 14 | @prefix waiver: . 15 | @prefix xhv: . 16 | @prefix xsd: . 17 | @prefix zbwext: . 18 | 19 | 20 | cc:attributionName "ZBW - Leibniz Information Centre for Economics"@en ; 21 | cc:morePermissions ; 22 | dcterms:issued "2013-10-30"^^xsd:date ; 23 | dcterms:publisher "ZBW - Leibniz Information Centre for Economics"@en ; 24 | xhv:alternate , , ; 25 | xhv:license ; 26 | xhv:stylesheet , , ; 27 | owl:versionInfo "8.12"@en . 28 | 29 | stw:version 30 | a dsv:VersionHistorySet ; 31 | dsv:currentVersionRecord . 32 | 33 | 34 | dc:date "2013-10-30"@en ; 35 | dc:identifier "8.12"@en ; 36 | a dsv:VersionHistoryRecord ; 37 | xhv:prev ; 38 | dsv:hasVersionHistorySet stw:version ; 39 | dsv:isVersionRecordOf . 40 | 41 | 42 | dc:date "2012-03-21"@en ; 43 | dc:identifier "8.10"@en ; 44 | a dsv:VersionHistoryRecord ; 45 | xhv:prev ; 46 | dsv:hasVersionHistorySet stw:version ; 47 | dsv:isVersionRecordOf . 48 | 49 | 50 | dc:date "2011-06-30"@en ; 51 | dc:identifier "8.08"@en ; 52 | a dsv:VersionHistoryRecord ; 53 | xhv:prev ; 54 | dsv:hasVersionHistorySet stw:version ; 55 | dsv:isVersionRecordOf . 56 | 57 | 58 | dc:date "2010-04-22"@en ; 59 | dc:identifier "8.06"@en ; 60 | a dsv:VersionHistoryRecord ; 61 | xhv:prev ; 62 | dsv:hasVersionHistorySet stw:version ; 63 | dsv:isVersionRecordOf . 64 | 65 | 66 | dc:date "2009-02-16"@en ; 67 | dc:identifier "8.04"@en ; 68 | a dsv:VersionHistoryRecord ; 69 | dsv:hasVersionHistorySet stw:version ; 70 | dsv:isVersionRecordOf . 71 | 72 | -------------------------------------------------------------------------------- /skos-history.ttl: -------------------------------------------------------------------------------- 1 | @prefix sh: . 2 | @prefix dc: . 3 | @prefix dcterms: . 4 | @prefix dsv: . 5 | @prefix owl: . 6 | @prefix rdf: . 7 | @prefix rdfs: . 8 | @prefix sd: . 9 | @prefix skos: . 10 | @prefix xsd: . 11 | 12 | # Ontology 13 | 14 | 15 | a owl:Ontology ; 16 | dc:creator "Joachim Neubert" ; 17 | dc:title "skos-history - Ontology for expressing version deltas of SKOS files"@en ; 18 | dcterms:created "2013-09-02"^^xsd:date ; 19 | dcterms:modified "2015-03-13"^^xsd:date ; 20 | dc:date "2015-03-13" ; 21 | rdfs:comment """This ontology proposal is meant to support comparisons between versions of SKOS vocabularies, both on the level of single concepts and on the level of aggregations of certain types of changes. The version deltas are expressed as graphs of insertions and deletions. 22 | The ontology may be used in conjunction with the proposed dataset versioning ontology (http://purl.org/iso25964/DataSet/Versioning#) for addressing the versions of a (SKOS) dataset via their related version history records."""@en . 23 | 24 | # Classes 25 | 26 | sh:SchemeDelta 27 | a rdfs:Class ; 28 | rdfs:isDefinedBy ; 29 | rdfs:label "Scheme Delta"@en ; 30 | rdfs:subClassOf skos:ConceptScheme ; 31 | rdfs:comment "The delta of two versions of a SKOS concept scheme."@en . 32 | 33 | sh:SchemeDeltaInsertions 34 | a rdfs:Class ; 35 | rdfs:comment """Should be related to the delta by dcterms:isPartOf."""@en ; 36 | rdfs:isDefinedBy ; 37 | rdfs:label "Scheme Delta Insertions"@en ; 38 | rdfs:subClassOf skos:ConceptScheme ; 39 | rdfs:comment "The statements to insert into one version of a SKOS concept scheme to create another version (in addition to deletions)."@en . 40 | 41 | sh:SchemeDeltaDeletions 42 | a rdfs:Class ; 43 | rdfs:comment """Should be related to the delta by dcterms:isPartOf."""@en ; 44 | rdfs:isDefinedBy ; 45 | rdfs:label "Scheme Delta Deletions"@en ; 46 | rdfs:subClassOf skos:ConceptScheme ; 47 | rdfs:comment "The statements to delete from one version of a SKOS concept scheme to create another version (in addition to insertions)."@en . 48 | 49 | # TODO are these needed?? 50 | 51 | sh:ConceptVersion 52 | a rdfs:Class ; 53 | rdfs:comment """Should be related to the concept by dcterms:isVersionOf."""@en ; 54 | rdfs:isDefinedBy ; 55 | rdfs:label "Concept Version"@en ; 56 | rdfs:subClassOf skos:Concept ; 57 | rdfs:comment "(???) A version of a SKOS concept."@en . 58 | 59 | sh:ConceptDelta 60 | a rdfs:Class ; 61 | rdfs:isDefinedBy ; 62 | rdfs:label "Concept Delta"@en ; 63 | # TODO that's not true! 64 | # rdfs:subClassOf skos:Concept ; 65 | rdfs:comment "The delta of two versions of a SKOS concept."@en . 66 | 67 | # Properties 68 | 69 | sh:usingNamedGraph 70 | a owl:ObjectProperty ; 71 | rdfs:isDefinedBy ; 72 | rdfs:label "using Named Graph"@en ; 73 | # TODO 74 | #rdfs:subPropertyOf ; 75 | rdfs:range sd:NamedGraph ; 76 | rdfs:comment "The named graph where the data can be queried. (The endpoint should be given as void:sparqlEndpoint property of the version history set.)"@en . 77 | 78 | sh:deltaFrom 79 | a owl:ObjectProperty ; 80 | rdfs:isDefinedBy ; 81 | rdfs:label "delta From"@en ; 82 | # TODO 83 | #rdfs:subPropertyOf ; 84 | rdfs:domain sh:SchemeDelta ; 85 | rdfs:comment "The version from which the delta is taken. The object of the triple may be a dsv:VersionHistoryRecord."@en . 86 | 87 | sh:deltaTo 88 | a owl:ObjectProperty ; 89 | rdfs:isDefinedBy ; 90 | rdfs:label "delta To"@en ; 91 | # TODO 92 | #rdfs:subPropertyOf ; 93 | rdfs:domain sh:SchemeDelta ; 94 | rdfs:comment "The versions to which the delta is taken. The object of the triple may be a dsv:VersionHistoryRecord."@en . 95 | 96 | sh:hasDelta 97 | a owl:ObjectProperty ; 98 | rdfs:isDefinedBy ; 99 | rdfs:label "has Delta"@en ; 100 | # TODO 101 | #rdfs:subPropertyOf ; 102 | rdfs:range sh:SchemeDelta ; 103 | rdfs:comment "A delta for this version. The subject of the triple may be a dsv:VersionHistoryRecord."@en . 104 | 105 | sh:isVersionHistoryOf 106 | a owl:ObjectProperty ; 107 | rdfs:isDefinedBy ; 108 | rdfs:label "is Version History Of"@en ; 109 | # TODO 110 | #rdfs:subPropertyOf ; 111 | #rdfs:range dsv:VersionHistorySet; 112 | #rdfs:domain skos:ConceptScheme . 113 | rdfs:comment "Links the version history set to the skos concept scheme it is about. (Preliminary, may be better located in dsv ontology.)"@en . 114 | 115 | # TODO check the following properties as possibly obsolete when using delta ontology 116 | 117 | sh:concepthistory 118 | a owl:ObjectProperty ; 119 | rdfs:isDefinedBy ; 120 | rdfs:label "concept History"@en ; 121 | # TODO 122 | #rdfs:subPropertyOf ; 123 | rdfs:comment "Collects the concept deltas of a concept (given in the subject of the triple)."@en . 124 | 125 | sh:prefLabelInsertion 126 | a owl:ObjectProperty ; 127 | rdfs:isDefinedBy ; 128 | rdfs:label "prefLabel Insertion"@en ; 129 | # TODO 130 | #rdfs:subPropertyOf ; 131 | rdfs:comment "skos:prefLabel which is to be inserted."@en . 132 | 133 | sh:prefLabelDeletion 134 | a owl:ObjectProperty ; 135 | rdfs:isDefinedBy ; 136 | rdfs:label "prefLabel Deletion"@en ; 137 | # TODO 138 | #rdfs:subPropertyOf ; 139 | rdfs:comment "skos:prefLabel which is to be deleted."@en . 140 | 141 | -------------------------------------------------------------------------------- /sparql/README.md: -------------------------------------------------------------------------------- 1 | SPARQL queries 2 | ============== 3 | 4 | The queries linked from this page provide examples on how a skos-history version store can be utilized to create useful change reports. The queries can be executed via an [interactive SPARQL GUI](http://zbw.eu/labs/en/blog/publishing-sparql-queries-live) against an [example endpoint](http://zbw.eu/beta/sparql/stwv/query) with different versions of [STW Thesaurus for Economics](http://zbw.eu/stw), prepared as s skos-history version store acccording to [Versions and Deltas as Named Graphs](https://github.com/jneubert/skos-history/wiki/Versions-and-Deltas-as-Named-Graphs). 5 | 6 | 7 | ## Generic queries for any SKOS vocabulary 8 | 9 | __Overview__ 10 | 11 | | Query | Description | 12 | |-------|-------------| 13 | | [version_overview](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/version_overview.rq) | Discover the version history graph and all available scheme versions | 14 | 15 | __Lists of concepts__ 16 | 17 | | Query | Description | 18 | |-------|-------------| 19 | [added_concepts](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/added_concepts.rq) | Identify all concepts inserted in the current version 20 | [added_concepts_with_top_concepts](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/added_concepts_with_top_concepts.rq) | Identify all concepts inserted in the current version with their top concepts 21 | [labels_moved_to_added_concepts](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/labels_moved_to_added_concepts.rq) | Show the labels which have moved to newly inserted concepts (flag new concepts if subordinated to the old one) 22 | [deprecated_concepts](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/deprecated_concepts.rq) | Identify all concepts deprecated with the current version 23 | [deleted_concepts](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/deleted_concepts.rq) | Identify all concepts deleted with the current version 24 | [changed_notations](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/changed_notations.rq) | For a classification (in this case the subject categories of STW), show which notation has changed 25 | 26 | __Aggregated information about versions__ 27 | 28 | | Query | Description | 29 | |-------|-------------| 30 | | [count_added_concepts](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/count_added_concepts.rq) | Count concepts inserted per version | 31 | | [count_deleted_concepts](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/count_deleted_concepts.rq) | Count concepts deleted per version | 32 | | [count_deprecated_concepts](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/count_deprecated_concepts.rq) | Count concepts deprecated per version | 33 | | [count_added_labels](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/count_added_labels.rq) | Count added alt/prefLabels in a certain language per version (may include formal changes, e.g. re capitalization) | 34 | | [count_deleted_labels](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/count_deleted_labels.rq) | Count deleted alt/prefLabels in a certain language per version (may include formal changes, e.g. re capitalization) | 35 | 36 | __History of selected concepts__ 37 | 38 | | Query | Description | 39 | |-------|-------------| 40 | | [concept_deltas](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/concept_deltas.rq) | All version deltas for the concept [Personnel selection](http://zbw.eu/stw/descriptor/12571-4) _(Insert other example concept uris into the VALUES clause - suggestions in the comment.)_ | 41 | | [concept_history](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/concept_history.rq) | Early alternative approach for the history of the concept [Personnel selection](http://zbw.eu/stw/descriptor/12571-4) (changes in pref/altLabels only) | 42 | 43 | __Technical background information__ 44 | 45 | | Query | Description | 46 | |-------|-------------| 47 | | [version_graph](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/version_graph.rq) | Complete version history graph | 48 | | [service_graph](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/service_graph.rq) | Complete service description graph (default graph) | 49 | 50 | __Extension to SKOS-XL__ 51 | 52 | Some of the example queries have been adapted to work against version of thesauri, which uses [SKOS-XL](http://www.w3.org/TR/skos-reference/skos-xl.html). The queries can be directed to the thesoz or agrovoc example endpoints (see below). 53 | 54 | 55 | ## Dataset-specific queries 56 | 57 | More often than not, SKOS publications contain information specific to the dataset in question. Dataset-specific queries may exploit and expose this additional information. 58 | 59 | - [STW Thesaurus for Economics](stw) (beta) 60 | - The experimental version stores for TheSoz, YSO, Agrovoc and GND subject headings are not available any more. 61 | 62 | So while the examples will not run with other datasets, they may show how 63 | value can be added by exploiting custom data structures, while at the same 64 | time making use of a common version history scheme. 65 | 66 | -------------------------------------------------------------------------------- /sparql/_template.rq: -------------------------------------------------------------------------------- 1 | # Template for skos-history queries 2 | # 3 | PREFIX dc: 4 | PREFIX dcterms: 5 | PREFIX dsv: 6 | PREFIX sd: 7 | PREFIX sh: 8 | PREFIX skos: 9 | PREFIX xhv: 10 | PREFIX zbwext: 11 | # 12 | SELECT DISTINCT * 13 | WHERE { 14 | GRAPH ?versionHistoryGraph { 15 | # parameters 16 | # (?versionHistoryGraph is required - should be scheme uri + '/version') 17 | VALUES ( ?versionHistoryGraph ?oldVersion ?newVersion ?language ) { 18 | ( undef undef undef "en" ) 19 | } 20 | # get the current and the previous version as default versions 21 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 22 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 23 | # select the versions to actually use 24 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 25 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 26 | # get the delta and via that the relevant graphs 27 | ?delta a sh:SchemeDelta ; 28 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 29 | sh:deltaTo/dc:identifier ?newVersionSelected ; 30 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 31 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph . 32 | ?deletions a sh:SchemeDeltaDeletions ; 33 | dcterms:isPartOf ?delta ; 34 | sh:usingNamedGraph/sd:name ?deletionsGraph . 35 | ?insertions a sh:SchemeDeltaInsertions ; 36 | dcterms:isPartOf ?delta ; 37 | sh:usingNamedGraph/sd:name ?insertionsGraph . 38 | } 39 | 40 | # ... 41 | 42 | } 43 | -------------------------------------------------------------------------------- /sparql/added_concepts.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX skosxl: 8 | PREFIX xhv: 9 | # 10 | # identify concepts inserted with a certain version 11 | # 12 | SELECT distinct (?concept AS ?addedConcept) (str(?prefLabel) AS ?addedConceptLabel) 13 | WHERE { 14 | GRAPH ?versionHistoryGraph { 15 | # parameters 16 | VALUES ( ?versionHistoryGraph ?oldVersion ?newVersion ?language ) { 17 | ( undef undef undef "en" ) 18 | } 19 | # get the current and the previous version as default versions 20 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 21 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 22 | # select the versions to actually use 23 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 24 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 25 | # get the delta and via that the relevant graphs 26 | ?delta a sh:SchemeDelta ; 27 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 28 | sh:deltaTo/dc:identifier ?newVersionSelected ; 29 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 30 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph . 31 | ?insertions a sh:SchemeDeltaInsertions ; 32 | dcterms:isPartOf ?delta ; 33 | sh:usingNamedGraph/sd:name ?insertionsGraph . 34 | ?deletions a sh:SchemeDeltaDeletions ; 35 | dcterms:isPartOf ?delta ; 36 | sh:usingNamedGraph/sd:name ?deletionsGraph . 37 | } 38 | # for each inserted concept, a newly inserted prefLabel must exist ... 39 | GRAPH ?insertionsGraph { 40 | ?concept skosxl:prefLabel/skosxl:literalForm | skos:prefLabel ?prefLabel 41 | } 42 | # ... and the concept must not exist in the old version 43 | FILTER NOT EXISTS { 44 | GRAPH ?oldVersionGraph { 45 | ?concept ?p [] 46 | } 47 | } 48 | # restrict output to a certain language 49 | FILTER ( lang(?prefLabel) = ?language ) 50 | } 51 | ORDER BY ?prefLabel 52 | -------------------------------------------------------------------------------- /sparql/added_concepts_with_top_concepts.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX skosxl: 8 | PREFIX xhv: 9 | # 10 | # Identify concepts inserted with a certain version, and show their top concepts 11 | # 12 | # For STW, top concepts always are defined 13 | # as a subsection of the thesaurus; a concept may have 14 | # multiple top concepts. 15 | # 16 | # For TheSoz, as of v0.93, skos:hasTopConcept is not used. 17 | # 18 | SELECT distinct ?topConcept (str(?topLabel) AS ?topConceptLabel) (?concept AS ?addedConcept) (str(?prefLabel) AS ?addedConceptLabel) 19 | WHERE { 20 | # parameters 21 | VALUES ( ?versionHistoryGraph ?language ) { 22 | ( undef "en" ) 23 | } 24 | GRAPH ?versionHistoryGraph { 25 | # the compared versions default to the current and the previous one 26 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?oldVersion . 27 | ?versionset dsv:currentVersionRecord/dc:identifier ?newVersion . 28 | # get the delta and via that the relevant graphs 29 | ?delta a sh:SchemeDelta ; 30 | sh:deltaFrom/dc:identifier ?oldVersion ; 31 | sh:deltaTo/dc:identifier ?newVersion ; 32 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 33 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 34 | dcterms:hasPart ?insertions ; 35 | dcterms:hasPart ?deletions . 36 | ?insertions a sh:SchemeDeltaInsertions ; 37 | sh:usingNamedGraph/sd:name ?insertionsGraph . 38 | ?deletions a sh:SchemeDeltaDeletions ; 39 | sh:usingNamedGraph/sd:name ?deletionsGraph . 40 | } 41 | # for each inserted concept, a (newly inserted) prefLabel must exist ... 42 | GRAPH ?insertionsGraph { 43 | ?concept skosxl:prefLabel | skos:prefLabel [] 44 | } 45 | # ... which did not exist in the old version 46 | FILTER NOT EXISTS { 47 | GRAPH ?oldVersionGraph { 48 | ?concept ?p [] 49 | } 50 | } 51 | GRAPH ?newVersionGraph { 52 | ?concept skosxl:prefLabel/skosxl:literalForm | skos:prefLabel ?prefLabel . 53 | # get the top concept(s) 54 | ?concept skos:broader+ ?topConcept . 55 | FILTER NOT EXISTS { 56 | ?topConcept skos:broader [] . 57 | } 58 | ?topConcept skosxl:prefLabel/skosxl:literalForm | skos:prefLabel ?topLabel . 59 | } 60 | # restrict output to a certain language 61 | FILTER (lang(?prefLabel) = ?language && lang(?topLabel) = ?language) 62 | } 63 | ORDER BY ?topLabel ?prefLabel 64 | -------------------------------------------------------------------------------- /sparql/changed_notations.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # Show thsys where notation changed (display prefLabel, because 12 | # these may have changed too) 13 | # 14 | SELECT (str(?oldNotation) AS ?old) (str(?newNotation) AS ?new) ?concept 15 | WHERE { 16 | # parameters 17 | VALUES ( ?versionHistoryGraph ?language ) { 18 | ( undef "en" ) 19 | } 20 | GRAPH ?versionHistoryGraph { 21 | # the compared versions default to the current and the previous one 22 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?oldVersion . 23 | ?versionset dsv:currentVersionRecord/dc:identifier ?newVersion . 24 | # get the delta and via that the relevant graphs 25 | ?delta a sh:SchemeDelta ; 26 | sh:deltaFrom/dc:identifier ?oldVersion ; 27 | sh:deltaTo/dc:identifier ?newVersion ; 28 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 29 | dcterms:hasPart ?insertions ; 30 | dcterms:hasPart ?deletions . 31 | ?insertions a sh:SchemeDeltaInsertions ; 32 | sh:usingNamedGraph/sd:name ?insertionsGraph . 33 | ?deletions a sh:SchemeDeltaDeletions ; 34 | sh:usingNamedGraph/sd:name ?deletionsGraph . 35 | } 36 | # get deleted concept/notations 37 | GRAPH ?deletionsGraph { 38 | ?concept skos:notation ?oldNotation . 39 | } 40 | # ... which have been re-inserted with another notation 41 | GRAPH ?insertionsGraph { 42 | ?concept skos:notation ?newNotation . 43 | } 44 | } 45 | ORDER BY ?oldNotation 46 | -------------------------------------------------------------------------------- /sparql/concept_deltas.rq: -------------------------------------------------------------------------------- 1 | PREFIX dcterms: 2 | PREFIX delta: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX rdfs: 6 | PREFIX sd: 7 | PREFIX sh: 8 | PREFIX skos: 9 | PREFIX xhv: 10 | # 11 | # version deltas for a single concept 12 | # 13 | # TODO: remove empty blank nodes (see 14 | # http://answers.semanticweb.com/questions/20908/sparql-construct-without-distinct-produces-non-lean-output) 15 | CONSTRUCT { 16 | ?concept sh:conceptHistory ?conceptDelta . 17 | ?conceptDelta a sh:ConceptDelta ; 18 | dcterms:isPartOf ?delta ; 19 | delta:deletion [ ?predicate ?deletion ] ; 20 | delta:insertion [ ?predicate ?insertion ] . 21 | } 22 | WHERE { 23 | # parameters 24 | VALUES ( ?versionHistoryGraph ?concept ) { 25 | ( undef ) 26 | } 27 | # alternate examples: 28 | # newly introduced thsys "B.04.02.01 Recruitment": 29 | # changes in "Welfare analyis": 30 | # complete lifecycle of "Virtual community": 31 | GRAPH ?versionHistoryGraph { 32 | # use subquery to filter out duplicates 33 | SELECT DISTINCT ?delta ?concept ?conceptDelta ?predicate ?deletion ?insertion 34 | WHERE { 35 | # get deltas of consecutive versions 36 | ?vhr a dsv:VersionHistoryRecord ; 37 | sh:hasDelta ?delta ; 38 | xhv:prev ?vhrPrev . 39 | ?delta sh:deltaTo ?vhr ; 40 | sh:deltaFrom ?vhrPrev . 41 | # identify insertions and deletions parts/graphs 42 | ?delta dcterms:hasPart ?insertions . 43 | ?insertions a sh:SchemeDeltaInsertions ; 44 | sh:usingNamedGraph/sd:name ?insertionsGraph . 45 | ?delta dcterms:hasPart ?deletions . 46 | ?deletions a sh:SchemeDeltaDeletions ; 47 | sh:usingNamedGraph/sd:name ?deletionsGraph . 48 | # 49 | # for each version, work on insertions and deletions part 50 | { 51 | GRAPH ?deletionsGraph { 52 | ?concept ?predicate ?deletion . 53 | } 54 | } UNION { 55 | GRAPH ?insertionsGraph { 56 | ?concept ?predicate ?insertion . 57 | } 58 | } 59 | # for the clarity of the example, filter out some dataset-wide changes in STW 60 | FILTER ( ?predicate NOT IN (, ) ) 61 | # build a uri to group the changes for a particular version 62 | # the general expression: 63 | #BIND (uri(concat(str(?concept), '/version', strafter(str(?delta), str(?versionHistoryGraph)))) AS ?conceptDelta) 64 | # does not work, so q+d we use an enumeration: 65 | BIND (uri(concat(str(?concept), strafter(str(?delta), "/stw"), strafter(str(?delta), "onto/yso"))) AS ?conceptDelta) 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /sparql/concept_history.rq: -------------------------------------------------------------------------------- 1 | PREFIX dcterms: 2 | PREFIX dsv: 3 | PREFIX skos: 4 | PREFIX sd: 5 | PREFIX sh: 6 | # 7 | # history of a single concept 8 | # (currently restricted to changes of skos:prefLabel/altLabel) 9 | # 10 | CONSTRUCT { 11 | ?concept sh:history ?conceptDelta . 12 | ?conceptDelta sh:prefLabelDeletion ?prefDelete ; 13 | sh:prefLabelInsertion ?prefInsert ; 14 | sh:altLabelDeletion ?altDelete ; 15 | sh:altLabelInsertion ?altInsert . 16 | } 17 | WHERE { 18 | GRAPH ?versionHistoryGraph { 19 | # parameters 20 | VALUES ( ?versionHistoryGraph ?concept ) { 21 | ( undef ) 22 | } 23 | ?vhr a dsv:VersionHistoryRecord . 24 | ?vhr sh:hasDelta ?delta . 25 | ?delta dcterms:hasPart ?part . 26 | # identify insertions and deletions parts/graphs 27 | ?delta dcterms:hasPart ?insertions . 28 | ?insertions a sh:SchemeDeltaInsertions . 29 | ?insertions sh:usingNamedGraph/sd:name ?insertionsGraph . 30 | ?delta dcterms:hasPart ?deletions . 31 | ?deletions a sh:SchemeDeltaDeletions . 32 | ?deletions sh:usingNamedGraph/sd:name ?deletionsGraph . 33 | } 34 | # for each version, work on insertions and deletions part 35 | { 36 | GRAPH ?deletionsGraph { 37 | ?concept ?somePred [] . 38 | OPTIONAL { 39 | ?concept skos:prefLabel ?prefDelete 40 | } . 41 | OPTIONAL { 42 | ?concept skos:altLabel ?altDelete 43 | } . 44 | } 45 | } UNION { 46 | GRAPH ?insertionsGraph { 47 | ?concept ?somePred [] . 48 | OPTIONAL { 49 | ?concept skos:prefLabel ?prefInsert 50 | } . 51 | OPTIONAL { 52 | ?concept skos:altLabel ?altInsert 53 | } . 54 | } 55 | } 56 | # build a uri to group the changes for a particular version 57 | BIND (uri(concat(str(?concept), strafter(str(?delta), "/stw"))) AS ?conceptDelta) 58 | } 59 | -------------------------------------------------------------------------------- /sparql/count_added_concepts.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX skosxl: 8 | PREFIX xhv: 9 | # 10 | # count concepts inserted per version 11 | # 12 | # note: for the STW, results differ from the STW-specific queries, 13 | # cf. Issue #26 (Incorrect results in standard count queries) 14 | # 15 | SELECT ?version ?oldVersion (str(count(distinct ?concept)) as ?addedConceptCount) 16 | WHERE { 17 | # parameters 18 | VALUES ( ?versionHistoryGraph ) { 19 | ( undef ) 20 | } 21 | # get deletiions and insertions graph for every version 22 | GRAPH ?versionHistoryGraph { 23 | ?delta a sh:SchemeDelta ; 24 | sh:deltaTo/dc:identifier ?version ; 25 | sh:deltaFrom/dc:identifier ?oldVersion ; 26 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 27 | dcterms:hasPart ?insertions ; 28 | dcterms:hasPart ?deletions . 29 | ?insertions a sh:SchemeDeltaInsertions ; 30 | sh:usingNamedGraph/sd:name ?insertionsGraph . 31 | ?deletions a sh:SchemeDeltaDeletions ; 32 | sh:usingNamedGraph/sd:name ?deletionsGraph . 33 | } 34 | # for each inserted concept, a (newly inserted) prefLabel must exist ... 35 | GRAPH ?insertionsGraph { 36 | ?concept skosxl:prefLabel|skos:prefLabel ?prefLabel 37 | } 38 | # ... which did not exist in the old version 39 | FILTER NOT EXISTS { 40 | GRAPH ?oldVersionGraph { 41 | ?concept ?p [] 42 | } 43 | } 44 | } 45 | GROUP BY ?version ?oldVersion 46 | ORDER BY ?version ?oldVersion 47 | -------------------------------------------------------------------------------- /sparql/count_added_labels.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX xhv: 8 | # 9 | # Count added labels in a certain language per version 10 | # 11 | SELECT ?version (str(count(distinct ?label)) AS ?addedLabelCount) 12 | WHERE { 13 | # parameters 14 | VALUES ( ?versionHistoryGraph ?language ) { 15 | ( undef "en" ) 16 | } 17 | GRAPH ?versionHistoryGraph { 18 | ?delta a sh:SchemeDelta ; 19 | sh:deltaTo/dc:identifier ?version ; 20 | dcterms:hasPart ?insertions ; 21 | dcterms:hasPart ?deletions . 22 | ?insertions a sh:SchemeDeltaInsertions ; 23 | sh:usingNamedGraph/sd:name ?insertionsGraph . 24 | ?deletions a sh:SchemeDeltaDeletions ; 25 | sh:usingNamedGraph/sd:name ?deletionsGraph . 26 | } 27 | # for each inserted label ... 28 | GRAPH ?insertionsGraph { 29 | [] skos:prefLabel | skos:altLabel ?label 30 | } 31 | # ... which was not attached to some (other) concept before 32 | FILTER NOT EXISTS { 33 | GRAPH ?deletionsGraph { 34 | [] skos:prefLabel | skos:altLabel ?label 35 | } 36 | } 37 | FILTER (lang(?label) = ?language) 38 | } 39 | GROUP BY ?version 40 | ORDER BY ?version 41 | -------------------------------------------------------------------------------- /sparql/count_deleted_concepts.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX skosxl: 8 | PREFIX xhv: 9 | # 10 | # count deleted concepts per version 11 | # 12 | SELECT ?version (str(count(distinct ?concept)) as ?deletedConceptCount) 13 | WHERE { 14 | # parameters 15 | VALUES ( ?versionHistoryGraph ) { 16 | ( undef ) 17 | } 18 | # get deletiions and insertions graph for every version 19 | GRAPH ?versionHistoryGraph { 20 | ?delta a sh:SchemeDelta ; 21 | sh:deltaTo/dc:identifier ?version ; 22 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 23 | dcterms:hasPart ?insertions ; 24 | dcterms:hasPart ?deletions . 25 | ?insertions a sh:SchemeDeltaInsertions ; 26 | sh:usingNamedGraph/sd:name ?insertionsGraph . 27 | ?deletions a sh:SchemeDeltaDeletions ; 28 | sh:usingNamedGraph/sd:name ?deletionsGraph . 29 | } 30 | # for each deleted concept, a deleted prefLabel must exist ... 31 | GRAPH ?deletionsGraph { 32 | ?concept skosxl:prefLabel|skos:prefLabel ?prefLabel 33 | } 34 | # ... without anything remaining for this concept in the current version 35 | FILTER NOT EXISTS { 36 | GRAPH ?newVersionGraph { 37 | ?concept ?p [] 38 | } 39 | } 40 | } 41 | GROUP BY ?version 42 | ORDER BY ?version 43 | -------------------------------------------------------------------------------- /sparql/count_deleted_labels.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX xhv: 8 | # 9 | # Count deleted labels in a certain language per version 10 | # 11 | SELECT ?version (str(count(distinct ?label)) as ?deletedLabelCount) 12 | WHERE { 13 | # parameters 14 | VALUES ( ?versionHistoryGraph ?language ) { 15 | ( undef "en" ) 16 | } 17 | GRAPH ?versionHistoryGraph { 18 | ?delta a sh:SchemeDelta ; 19 | sh:deltaTo/dc:identifier ?version ; 20 | dcterms:hasPart ?insertions ; 21 | dcterms:hasPart ?deletions . 22 | ?insertions a sh:SchemeDeltaInsertions ; 23 | sh:usingNamedGraph/sd:name ?insertionsGraph . 24 | ?deletions a sh:SchemeDeltaDeletions ; 25 | sh:usingNamedGraph/sd:name ?deletionsGraph . 26 | } 27 | # for each deleted label ... 28 | GRAPH ?deletionsGraph { 29 | [] skos:prefLabel | skos:altLabel ?label 30 | } 31 | # ... without being inserted otherwise (for another concept or property) 32 | FILTER NOT EXISTS { 33 | GRAPH ?insertionsGraph { 34 | [] skos:prefLabel | skos:altLabel ?label 35 | } 36 | } 37 | FILTER (lang(?label) = ?language) 38 | } 39 | GROUP BY ?version 40 | ORDER BY ?version 41 | -------------------------------------------------------------------------------- /sparql/count_deprecated_concepts.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | # 10 | # count deprecated concepts per version 11 | # 12 | SELECT ?version (str(count(?concept)) as ?deprecatedConceptCount) 13 | WHERE { 14 | # parameters 15 | VALUES ( ?versionHistoryGraph ) { 16 | ( undef ) 17 | } 18 | GRAPH ?versionHistoryGraph { 19 | ?delta a sh:SchemeDelta . 20 | ?delta sh:deltaTo/dc:identifier ?version . 21 | # identify insertions and deletions parts/graphs 22 | ?delta dcterms:hasPart ?insertions . 23 | ?insertions a sh:SchemeDeltaInsertions . 24 | ?insertions sh:usingNamedGraph/sd:name ?insertionsGraph . 25 | ?delta dcterms:hasPart ?deletions . 26 | ?deletions a sh:SchemeDeltaDeletions . 27 | ?deletions sh:usingNamedGraph/sd:name ?deletionsGraph . 28 | } 29 | # identify the deprecated concepts 30 | GRAPH ?insertionsGraph { 31 | ?concept owl:deprecated true 32 | } 33 | } 34 | GROUP BY ?version 35 | ORDER BY ?version 36 | -------------------------------------------------------------------------------- /sparql/deleted_concepts.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX skosxl: 8 | PREFIX xhv: 9 | # 10 | # identify concepts deleted with a certain version 11 | # 12 | # (In published vocabularies, the deletion of concepts should be regarded 13 | # as bad practice, because they still may be referenced elsewhere. 14 | # Cosider using owl:deprecated instead) 15 | # 16 | SELECT distinct (?concept AS ?deletedConcept) (str(?prefLabel) AS ?deletedConceptLabel) 17 | WHERE { 18 | # parameters 19 | VALUES ( ?versionHistoryGraph ?oldVersion ?newVersion ?language ) { 20 | ( undef undef undef "en" ) 21 | } 22 | GRAPH ?versionHistoryGraph { 23 | # get the current and the previous version as default versions 24 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 25 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 26 | # select the versions to actually use 27 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 28 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 29 | # get the delta and via that the relevant graphs 30 | ?delta a sh:SchemeDelta ; 31 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 32 | sh:deltaTo/dc:identifier ?newVersionSelected ; 33 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 34 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 35 | dcterms:hasPart ?insertions ; 36 | dcterms:hasPart ?deletions . 37 | ?insertions a sh:SchemeDeltaInsertions ; 38 | sh:usingNamedGraph/sd:name ?insertionsGraph . 39 | ?deletions a sh:SchemeDeltaDeletions ; 40 | sh:usingNamedGraph/sd:name ?deletionsGraph . 41 | } 42 | # for each deleted concept, a deleted prefLabel must exist ... 43 | GRAPH ?deletionsGraph { 44 | ?concept skosxl:prefLabel | skos:prefLabel [] 45 | } 46 | # ... without anything remaining for this concept in the current version 47 | FILTER NOT EXISTS { 48 | GRAPH ?newVersionGraph { 49 | ?concept ?p [] 50 | } 51 | } 52 | # get the label 53 | GRAPH ?oldVersionGraph { 54 | ?concept skosxl:prefLabel/skosxl:literalForm | skos:prefLabel ?prefLabel 55 | } 56 | # restrict output to a certain language 57 | FILTER (lang(?prefLabel) = ?language) 58 | } 59 | ORDER BY ?concept 60 | -------------------------------------------------------------------------------- /sparql/deprecated_concepts.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX rdfs: 6 | PREFIX sd: 7 | PREFIX sh: 8 | PREFIX skos: 9 | PREFIX xhv: 10 | # 11 | # identify concepts deprecated with a certain version 12 | # 13 | SELECT (?concept AS ?deprecatedConcept) (str(?label) AS ?deprecatedConceptLabel) 14 | (?replacedBy as ?replacedByConcept) (str(?replacedByPrefLabel) AS ?replacedByConceptLabel) 15 | WHERE { 16 | GRAPH ?versionHistoryGraph { 17 | # parameters 18 | VALUES ( ?versionHistoryGraph ?oldVersion ?newVersion ?language ) { 19 | ( undef undef undef "en" ) 20 | } 21 | # get the current and the previous version as default versions 22 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 23 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 24 | # select the versions to actually use 25 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 26 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 27 | # get the delta and via that the relevant graphs 28 | ?delta a sh:SchemeDelta ; 29 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 30 | sh:deltaTo/dc:identifier ?newVersionSelected ; 31 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 32 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 33 | dcterms:hasPart ?insertions ; 34 | dcterms:hasPart ?deletions . 35 | ?insertions a sh:SchemeDeltaInsertions ; 36 | sh:usingNamedGraph/sd:name ?insertionsGraph . 37 | ?deletions a sh:SchemeDeltaDeletions ; 38 | sh:usingNamedGraph/sd:name ?deletionsGraph . 39 | } 40 | # identify the deprecated concepts 41 | GRAPH ?insertionsGraph { 42 | ?concept owl:deprecated true 43 | } 44 | GRAPH ?newVersionGraph { 45 | # different kinds of remaining labels should be supported 46 | { 47 | ?concept skos:prefLabel ?label 48 | } 49 | UNION 50 | { 51 | ?concept rdfs:label ?label 52 | } 53 | # perhaps the deprecated concept was merged into another one 54 | OPTIONAL { 55 | ?concept dcterms:isReplacedBy ?replacedBy . 56 | ?replacedBy skos:prefLabel ?replacedByPrefLabel . 57 | FILTER (lang(?label) = lang(?replacedByPrefLabel)) 58 | } 59 | } 60 | # restrict output to a certain language 61 | FILTER (lang(?label) = ?language) 62 | } 63 | ORDER BY ?concept 64 | -------------------------------------------------------------------------------- /sparql/jel/README.md: -------------------------------------------------------------------------------- 1 | ## Queries for the Jornal of Economics Literature Classification System (JEL) 2 | 3 | These are not special queries for JEL, but links to queries existing elsewhere, provided here for convenience. 4 | 5 | ### Added and deleted concepts 6 | 7 | Query | Description 8 | ------|------------ 9 | [added_concepts](http://zbw.eu/beta/sparql-lab/?endpoint=http://zbw.eu/beta/sparql/jelv/query&queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/added_concepts.rq) | added_concepts (latest version) 10 | [deleted_concepts](http://zbw.eu/beta/sparql-lab/?endpoint=http://zbw.eu/beta/sparql/jelv/query&queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/deleted_concepts.rq) | deleted_concepts (latest version) 11 | [added_concepts (aggregated)](http://zbw.eu/beta/sparql-lab/?endpoint=http://zbw.eu/beta/sparql/jelv/query&queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/added_concepts.rq&oldVersion=2008-10&newVersion=2017-01) | All added concepts (from 2008-10 on) 12 | [deleted_concepts (aggregated)](http://zbw.eu/beta/sparql-lab/?endpoint=http://zbw.eu/beta/sparql/jelv/query&queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/deleted_concepts.rq&oldVersion=2008-10&newVersion=2017-01) | All deleted concepts (from 2008-10 on) 13 | 14 | 15 | ### Technical background information 16 | 17 | _NOTE: The original JEL download files do not come with version identifiers. The Linked Data downloads on http://zbw.eu/beta/external_identifiers/jel/ carry version dates and identifiers, which reflect to (rather arbitrary) time of the download. Because the files were extracted from language-specific RDFa pages, some of the version strings carry language tags and must be referenced as, e.g., `"2012-09"@en`._ 18 | 19 | Query | Description 20 | ------|------------ 21 | [dummy](http://zbw.eu/beta/sparql-lab/?endpoint=http://zbw.eu/beta/sparql/jelv/query&queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/dummy.rq) | dummy 22 | [graph_overview_simple](http://zbw.eu/beta/sparql-lab/?endpoint=http://zbw.eu/beta/sparql/jelv/query&queryRef=https://api.github.com/repos/zbw/sparql-queries/contents/graph_overview_simple.rq) | graph_overview_simple 23 | [version_overview](http://zbw.eu/beta/sparql-lab/?endpoint=http://zbw.eu/beta/sparql/jelv/query&queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/version_overview.rq) | version_overview 24 | 25 | -------------------------------------------------------------------------------- /sparql/labels_moved_to_added_concepts.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # Show the labels which have moved to newly inserted concepts 12 | # 13 | SELECT distinct ?oldConcept (str(?oldPrefLabel) as ?oldConceptLabel) (str(?label) AS ?movedLabel) 14 | ?newConcept (str(?newPrefLabel) as ?newConceptLabel) ?isSubconcept 15 | WHERE { 16 | GRAPH ?versionHistoryGraph { 17 | # parameters 18 | VALUES ( ?versionHistoryGraph ?oldVersion ?newVersion ?language ) { 19 | ( undef undef undef "en" ) 20 | } 21 | # get the current and the previous version as default versions 22 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 23 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 24 | # select the versions to actually use 25 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 26 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 27 | # get the delta and via that the relevant graphs 28 | ?delta a sh:SchemeDelta ; 29 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 30 | sh:deltaTo/dc:identifier ?newVersionSelected ; 31 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 32 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 33 | dcterms:hasPart ?insertions ; 34 | dcterms:hasPart ?deletions . 35 | ?insertions a sh:SchemeDeltaInsertions ; 36 | sh:usingNamedGraph/sd:name ?insertionsGraph . 37 | ?deletions a sh:SchemeDeltaDeletions ; 38 | sh:usingNamedGraph/sd:name ?deletionsGraph . 39 | } 40 | # get deleted labels (in all languages) ... 41 | GRAPH ?deletionsGraph { 42 | ?oldConcept skos:prefLabel | skos:altLabel ?label . 43 | } 44 | # ... which have been moved to another concept (or perhaps have got another labelType) 45 | GRAPH ?insertionsGraph { 46 | ?newConcept skos:prefLabel | skos:altLabel ?label . 47 | } 48 | # restrict to actual movements 49 | FILTER (?oldConcept != ?newConcept) 50 | # 51 | # restrict target concepts to newly inserted ones 52 | FILTER NOT EXISTS { 53 | GRAPH ?oldVersionGraph { 54 | ?newConcept ?p [] . 55 | } 56 | } 57 | GRAPH ?oldVersionGraph { 58 | ?oldConcept skos:prefLabel ?oldPrefLabel . 59 | } 60 | GRAPH ?newVersionGraph { 61 | ?newConcept skos:prefLabel ?newPrefLabel . 62 | } 63 | # flag if the new concept is directly sub-ordinated to the old one 64 | OPTIONAL { 65 | GRAPH ?newVersionGraph { 66 | ?oldConcept skos:narrower ?newConcept 67 | BIND (true AS ?isSubconcept) 68 | } 69 | } 70 | FILTER (lang(?label) = ?language 71 | && lang(?oldPrefLabel) = ?language 72 | && lang(?newPrefLabel) = ?language ) 73 | } 74 | ORDER BY ?newPrefLabel ?label 75 | -------------------------------------------------------------------------------- /sparql/service_graph.rq: -------------------------------------------------------------------------------- 1 | PREFIX dcterms: 2 | PREFIX sd: 3 | # 4 | # the service description (default) graph 5 | # 6 | CONSTRUCT { 7 | ?s ?p ?o . 8 | } 9 | WHERE { 10 | ?s ?p ?o 11 | } 12 | -------------------------------------------------------------------------------- /sparql/stw/README.md: -------------------------------------------------------------------------------- 1 | STW Thesaurus for Economics 2 | ========================= 3 | 4 | Queries on [STW Thesaurus for Economics](http://zbw.eu/stw), which contains subthesauri and a hierarchy of general subject categories (thesaurus groups in [ISO-25964](https://en.wikipedia.org/wiki/ISO_25964)). These queries are used for generating the change reports on STW production site: [8.14 reports (beta)](http://zbw.eu/stw/version/8.14/changes) are generated live, while [9.0 reports](http://zbw.eu/stw/version/9.0/changes) and [reports on accumulated changes 8.06-9.0](http://zbw.eu/stw/version/latest/relaunch) rely on pre-computed JSON files. 5 | 6 | 7 | __Lists of individual changes__ 8 | 9 | Query | Description 10 | ------|------------ 11 | [added_concepts_by_category](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/added_concepts_by_category.rq) | Added STW concepts (by default: descriptors) by second-level category 12 | [deprecated_concepts_by_category](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/deprecated_concepts_by_category.rq) | Deprecated STW concepts (by default: descriptors) by second-level category 13 | [added_labels](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/added_labels.rq) | Added descriptor labels (pref/altLabels) 14 | [deleted_labels](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/deleted_labels.rq) | Deleted descriptor labels (pref/altLabels) 15 | [moved_labels](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/moved_labels.rq) | Moved pref/altLabels 16 | [merged_partially](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/merged_partially.rq) | Partially merged deprecated concepts 17 | [changed_preferred_labels](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/changed_preferred_labels.rq) | Show concepts (by default:descriptors) where the preferred labels has changed, and link to RDFa pages accordingly (for thsys, this includes notation changes) 18 | [moved_categories_subthes](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/moved_categories_subthes.rq) | Show categories which have been moved to another sub-thesaurus (skos:topConcept) 19 | [added_narrower](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/added_narrower.rq) | Added narrower relations to already existing concepts (newly introduced narrower concepts flagged) 20 | [added_broader](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/added_broader.rq) | Added broader relations to already existing concepts (newly introduced broader concepts flagged) 21 | 22 | 23 | __Aggregated information about versions__ 24 | 25 | Query | Description 26 | ------|------------ 27 | [count_added_concepts_by_category](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/count_added_concepts_by_category.rq) | Count added STW concepts by second-level category 28 | [count_deprecated_concepts_by_category](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/count_deprecated_concepts_by_category.rq) | Count deprecated STW concepts by second-level category 29 | [count_added_concepts_by_top](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/count_added_concepts_by_top.rq) | Count added STW concepts by sub-thesaurus (topConcept) 30 | [count_deprecated_concepts_by_top](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/count_deprecated_concepts_by_top.rq) | Count deprecated STW concepts by sub-thesaurus (topConcept) 31 | [count_added_concepts](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/count_added_concepts.rq) | Count added STW concepts (of a certain concept type) per version 32 | [count_deprecated_concepts](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/count_deprecated_concepts.rq) | Count deprecated STW concepts per version 33 | [count_added_labels](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/count_added_labels.rq) | Count added alt/prefLabels for STW descriptors in a certain language per version 34 | [count_deleted_labels](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/count_deleted_labels.rq) | Count deleted alt/prefLabels for STW descriptors in a certain language per version 35 | [count_concepts](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/count_concepts.rq) | Count STW concepts (of a certain concept type) per version 36 | 37 | 38 | -------------------------------------------------------------------------------- /sparql/stw/_template.rq: -------------------------------------------------------------------------------- 1 | # (Template for STW version queries) 2 | # 3 | PREFIX dc: 4 | PREFIX dcterms: 5 | PREFIX dsv: 6 | PREFIX sd: 7 | PREFIX sh: 8 | PREFIX skos: 9 | PREFIX xhv: 10 | PREFIX zbwext: 11 | # 12 | SELECT DISTINCT * 13 | WHERE { 14 | GRAPH ?versionHistoryGraph { 15 | # parameters 16 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 17 | ( zbwext:Descriptor undef undef "en" ) 18 | } 19 | # get the current and the previous version as default versions 20 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 21 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 22 | # select the versions to actually use 23 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 24 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 25 | # get the delta and via that the relevant graphs 26 | ?delta a sh:SchemeDelta ; 27 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 28 | sh:deltaTo/dc:identifier ?newVersionSelected ; 29 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 30 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 31 | dcterms:hasPart ?insertions ; 32 | dcterms:hasPart ?deletions . 33 | ?deletions a sh:SchemeDeltaDeletions ; 34 | sh:usingNamedGraph/sd:name ?deletionsGraph . 35 | ?insertions a sh:SchemeDeltaInsertions ; 36 | sh:usingNamedGraph/sd:name ?insertionsGraph . 37 | } 38 | 39 | # ... 40 | 41 | } 42 | -------------------------------------------------------------------------------- /sparql/stw/added_broader.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # Added broader relations to already existing concepts 12 | # (newly introduced broader concepts flagged) 13 | # 14 | SELECT DISTINCT ?concept (str(?conceptPrefLabel) AS ?conceptLabel) 15 | ?priorIntermediateConcept (str(?intermediateLabel) AS ?priorIntermediateConceptLabel) 16 | (?broaderConcept AS ?addedBroaderConcept) (str(?broaderConceptPrefLabel) as ?addedBroaderConceptLabel) 17 | ?isNew 18 | WHERE { 19 | GRAPH ?versionHistoryGraph { 20 | # parameters 21 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 22 | ( zbwext:Descriptor undef undef "en" ) 23 | } 24 | # get the current and the previous version as default versions 25 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 26 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 27 | # select the versions to actually use 28 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 29 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 30 | # get the delta and via that the relevant graphs 31 | ?delta a sh:SchemeDelta ; 32 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 33 | sh:deltaTo/dc:identifier ?newVersionSelected ; 34 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 35 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 36 | dcterms:hasPart ?insertions ; 37 | dcterms:hasPart ?deletions . 38 | ?deletions a sh:SchemeDeltaDeletions ; 39 | sh:usingNamedGraph/sd:name ?deletionsGraph . 40 | ?insertions a sh:SchemeDeltaInsertions ; 41 | sh:usingNamedGraph/sd:name ?insertionsGraph . 42 | } 43 | # newly inserted broader relations 44 | GRAPH ?insertionsGraph { 45 | ?concept skos:broader ?broaderConcept . 46 | } 47 | # ... for already existing concepts 48 | FILTER exists { 49 | GRAPH ?oldVersionGraph { 50 | ?concept ?p [] 51 | } 52 | } 53 | # restrict to ?conceptType 54 | GRAPH ?newVersionGraph { 55 | ?concept a ?conceptType ; 56 | skos:prefLabel ?conceptPrefLabel . 57 | ?broaderConcept a ?conceptType ; 58 | skos:prefLabel ?broaderConceptPrefLabel . 59 | OPTIONAL { 60 | ?broaderConcept skos:notation ?notation . 61 | } 62 | } 63 | # intermediate concept in the prior version (if exists) 64 | OPTIONAL { 65 | GRAPH ?oldVersionGraph { 66 | ?concept skos:broader ?priorIntermediateConcept . 67 | ?priorIntermediateConcept skos:broader ?broaderConcept ; 68 | skos:prefLabel ?intermediateLabel . 69 | } 70 | FILTER (lang(?intermediateLabel) = ?language) 71 | } 72 | # flag broader concepts which were newly introduced 73 | OPTIONAL { 74 | BIND (true AS ?isNew) 75 | FILTER not exists { 76 | GRAPH ?oldVersionGraph { 77 | ?broaderConcept ?p [] . 78 | } 79 | } 80 | } 81 | FILTER (lang(?conceptPrefLabel) = ?language && lang(?broaderConceptPrefLabel) = ?language) 82 | } 83 | ORDER BY ?conceptPrefLabel ?notation ?broaderConceptPrefLabel 84 | 85 | -------------------------------------------------------------------------------- /sparql/stw/added_by_category_3levels.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX xhv: 8 | PREFIX zbwext: 9 | # 10 | # Identify concepts inserted with a certain version, 11 | # ordered by the subject categories (down to the third level). 12 | # 13 | # Subject categories have a different concept type (subclass of 14 | # skos:Concept) and form mono-hierarchies within STW. The top 15 | # level subject categories are the sub-thesauri. A descriptor 16 | # often belongs to more than one subject category. 17 | # 18 | SELECT DISTINCT ?topCategory (str(?topLabel) AS ?topCategoryLabel) ?secondLevelCategory (str(?secondLevelLabel) AS ?secondLevelCategoryLabel) ?thirdLevelCategory (coalesce(str(?thirdLevelLabel), "") AS ?thirdLevelCategoryLabel) (?concept AS ?addedConcept) (str(?prefLabel) AS ?addedConceptLabel) 19 | WHERE { 20 | GRAPH ?versionHistoryGraph { 21 | # parameters 22 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 23 | ( zbwext:Descriptor undef undef "en" ) 24 | } 25 | # get the current and the previous version as default versions 26 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 27 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 28 | # select the versions to actually use 29 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 30 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 31 | # get the delta and via that the relevant graphs 32 | ?delta a sh:SchemeDelta ; 33 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 34 | sh:deltaTo/dc:identifier ?newVersionSelected ; 35 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 36 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 37 | dcterms:hasPart ?insertions ; 38 | dcterms:hasPart ?deletions . 39 | ?deletions a sh:SchemeDeltaDeletions ; 40 | sh:usingNamedGraph/sd:name ?deletionsGraph . 41 | ?insertions a sh:SchemeDeltaInsertions ; 42 | sh:usingNamedGraph/sd:name ?insertionsGraph . 43 | } 44 | # for each inserted concept, a (newly inserted) prefLabel must exist ... 45 | GRAPH ?insertionsGraph { 46 | ?concept skos:prefLabel ?prefLabel 47 | } 48 | # ... without any prefLabel deleted for this concept 49 | FILTER NOT EXISTS { 50 | GRAPH ?oldVersionGraph { 51 | ?concept ?p [] 52 | } 53 | } 54 | GRAPH ?newVersionGraph { 55 | # get the top subject category (concept of subclass Thsys) 56 | # subject categories form a mono-hierarchy within STW 57 | ?concept skos:prefLabel ?prefLabel . 58 | ?concept skos:broader ?category . 59 | ?category a zbwext:Thsys . 60 | ?category skos:broader* ?topCategory . 61 | ?scheme skos:hasTopConcept ?topCategory . 62 | ?topCategory skos:prefLabel ?topLabel . 63 | # 64 | # get the second level category and it's label 65 | ?topCategory skos:narrower ?secondLevelCategory . 66 | ?category skos:broader+ ?secondLevelCategory . 67 | ?secondLevelCategory skos:prefLabel ?secondLevelLabel . 68 | # 69 | # get the third level category and it's label 70 | OPTIONAL { 71 | ?secondLevelCategory skos:narrower ?thirdLevelCategory . 72 | ?category skos:broader+ ?thirdLevelCategory . 73 | ?thirdLevelCategory skos:prefLabel ?thirdLevelLabel . 74 | } 75 | } 76 | FILTER (lang(?prefLabel) = ?language && lang(?secondLevelLabel) = ?language && lang(?topLabel) = ?language) 77 | FILTER (!bound(?thirdLevelLabel) || lang(?thirdLevelLabel) = ?language) 78 | } 79 | ORDER BY ?secondLevelCategoryLabel ?thirdLevelCategoryLabel ?prefLabel 80 | -------------------------------------------------------------------------------- /sparql/stw/added_concepts_by_category.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX xhv: 8 | PREFIX zbwext: 9 | # 10 | # Identify concepts inserted with a certain version, 11 | # ordered by the subject categories (first and second level). 12 | # 13 | # Subject categories have a different concept type (subclass of 14 | # skos:Concept) and form mono-hierarchies within STW. The top 15 | # level subject categories are the sub-thesauri. A descriptor 16 | # often belongs to more than one subject category. 17 | # 18 | SELECT DISTINCT ?secondLevelCategory (str(?secondLevelLabel) AS ?secondLevelCategoryLabel) 19 | (?concept AS ?addedConcept) (str(?prefLabel) AS ?addedConceptLabel) 20 | WHERE { 21 | GRAPH ?versionHistoryGraph { 22 | # parameters 23 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 24 | ( zbwext:Descriptor undef undef "en" ) 25 | } 26 | # get the current and the previous version as default versions 27 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 28 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 29 | # select the versions to actually use 30 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 31 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 32 | # get the delta and via that the relevant graphs 33 | ?delta a sh:SchemeDelta ; 34 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 35 | sh:deltaTo/dc:identifier ?newVersionSelected ; 36 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 37 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 38 | dcterms:hasPart ?insertions ; 39 | dcterms:hasPart ?deletions . 40 | ?deletions a sh:SchemeDeltaDeletions ; 41 | sh:usingNamedGraph/sd:name ?deletionsGraph . 42 | ?insertions a sh:SchemeDeltaInsertions ; 43 | sh:usingNamedGraph/sd:name ?insertionsGraph . 44 | } 45 | # for each inserted concept, a (newly inserted) prefLabel must exist ... 46 | GRAPH ?insertionsGraph { 47 | ?concept skos:prefLabel ?prefLabel 48 | } 49 | # ... without any triples for this concept in the old version 50 | FILTER NOT EXISTS { 51 | GRAPH ?oldVersionGraph { 52 | ?concept ?p [] 53 | } 54 | } 55 | GRAPH ?newVersionGraph { 56 | # get the top subject category (concept of subclass Thsys) 57 | # subject categories form a mono-hierarchy within STW 58 | ?concept a ?conceptType ; 59 | skos:prefLabel ?prefLabel ; 60 | skos:broader ?category . 61 | ?category a zbwext:Thsys ; 62 | skos:broader* ?topCategory . 63 | $scheme skos:hasTopConcept $topCategory . 64 | # 65 | # get the second level category and it's label 66 | ?topCategory skos:narrower ?secondLevelCategory . 67 | ?category skos:broader* ?secondLevelCategory . 68 | ?secondLevelCategory skos:prefLabel ?secondLevelLabel . 69 | } 70 | FILTER (lang(?prefLabel) = ?language && lang(?secondLevelLabel) = ?language) 71 | } 72 | ORDER BY ?secondLevelCategoryLabel ?prefLabel 73 | 74 | -------------------------------------------------------------------------------- /sparql/stw/added_labels.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX xhv: 8 | PREFIX zbwext: 9 | # 10 | # Show all labels added in the current version 11 | # 12 | SELECT DISTINCT ?concept (str(?prefLabel) as ?conceptLabel) (str(?label) AS ?addedLabel) 13 | WHERE { 14 | GRAPH ?versionHistoryGraph { 15 | # parameters 16 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 17 | ( zbwext:Descriptor undef undef "en" ) 18 | } 19 | # get the current and the previous version as default versions 20 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 21 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 22 | # select the versions to actually use 23 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 24 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 25 | # get the delta and via that the relevant graphs 26 | ?delta a sh:SchemeDelta ; 27 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 28 | sh:deltaTo/dc:identifier ?newVersionSelected ; 29 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 30 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 31 | dcterms:hasPart ?insertions ; 32 | dcterms:hasPart ?deletions . 33 | ?deletions a sh:SchemeDeltaDeletions ; 34 | sh:usingNamedGraph/sd:name ?deletionsGraph . 35 | ?insertions a sh:SchemeDeltaInsertions ; 36 | sh:usingNamedGraph/sd:name ?insertionsGraph . 37 | } 38 | # get all labels 39 | GRAPH ?insertionsGraph { 40 | [] skos:prefLabel | skos:altLabel ?label 41 | } 42 | # ... which were not attached to some (other) concept before 43 | FILTER NOT EXISTS { 44 | GRAPH ?deletionsGraph { 45 | [] skos:prefLabel | skos:altLabel ?label 46 | } 47 | } 48 | FILTER (lang(?label) = ?language) 49 | GRAPH ?newVersionGraph { 50 | # get concepts and restrict to conceptType 51 | # (no variant for type URI since newVersion 8.06) 52 | ?concept skos:prefLabel | skos:altLabel ?label ; 53 | a ?conceptType ; 54 | skos:prefLabel ?prefLabel . 55 | } 56 | # restrict output to a certain language 57 | FILTER (lang(?prefLabel) = ?language) 58 | } 59 | ORDER BY ?label 60 | -------------------------------------------------------------------------------- /sparql/stw/added_narrower.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # Added narrower relations to already existing concepts 12 | # (newly introduced narrower concepts flagged) 13 | # 14 | SELECT DISTINCT ?concept (str(?conceptPrefLabel) AS ?conceptLabel) 15 | ?priorIntermediateConcept (str(?intermediateLabel) AS ?priorIntermediateConceptLabel) 16 | (?narrowerConcept AS ?addedNarrowerConcept) (str(?narrowerConceptPrefLabel) as ?addedNarrowerConceptLabel) 17 | ?isNew 18 | WHERE { 19 | GRAPH ?versionHistoryGraph { 20 | # parameters 21 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 22 | ( zbwext:Descriptor undef undef "en" ) 23 | } 24 | # get the current and the previous version as default versions 25 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 26 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 27 | # select the versions to actually use 28 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 29 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 30 | # get the delta and via that the relevant graphs 31 | ?delta a sh:SchemeDelta ; 32 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 33 | sh:deltaTo/dc:identifier ?newVersionSelected ; 34 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 35 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 36 | dcterms:hasPart ?insertions ; 37 | dcterms:hasPart ?deletions . 38 | ?deletions a sh:SchemeDeltaDeletions ; 39 | sh:usingNamedGraph/sd:name ?deletionsGraph . 40 | ?insertions a sh:SchemeDeltaInsertions ; 41 | sh:usingNamedGraph/sd:name ?insertionsGraph . 42 | } 43 | # newly inserted narrower relations 44 | GRAPH ?insertionsGraph { 45 | ?concept skos:narrower ?narrowerConcept . 46 | } 47 | # ... for already existing concepts 48 | FILTER exists { 49 | GRAPH ?oldVersionGraph { 50 | ?concept ?p [] 51 | } 52 | } 53 | # restrict to ?conceptType 54 | GRAPH ?newVersionGraph { 55 | ?concept a ?conceptType ; 56 | skos:prefLabel ?conceptPrefLabel . 57 | ?narrowerConcept a ?conceptType ; 58 | skos:prefLabel ?narrowerConceptPrefLabel . 59 | OPTIONAL { 60 | ?narrowerConcept skos:notation ?notation . 61 | } 62 | } 63 | # intermediate concept in the prior version (if exists) 64 | OPTIONAL { 65 | GRAPH ?oldVersionGraph { 66 | ?concept skos:narrower ?priorIntermediateConcept . 67 | ?priorIntermediateConcept skos:narrower ?narrowerConcept ; 68 | skos:prefLabel ?intermediateLabel . 69 | } 70 | FILTER (lang(?intermediateLabel) = ?language) 71 | } 72 | # flag narrower concepts which were newly introduced 73 | OPTIONAL { 74 | BIND (true AS ?isNew) 75 | FILTER not exists { 76 | GRAPH ?oldVersionGraph { 77 | ?narrowerConcept ?p [] . 78 | } 79 | } 80 | } 81 | FILTER (lang(?conceptPrefLabel) = ?language && lang(?narrowerConceptPrefLabel) = ?language) 82 | } 83 | ORDER BY ?conceptPrefLabel ?notation ?narrowerConceptPrefLabel 84 | -------------------------------------------------------------------------------- /sparql/stw/changed_notations_thsys.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # Show thsys where notation changed, and link to RDFa pages accordingly 12 | # 13 | # (display prefLabel, because these may have changed too) 14 | # 15 | SELECT ?old (str(?oldPrefLabel) AS ?oldLabel) (str(?newPrefLabel) AS ?newLabel) ?new 16 | WHERE { 17 | GRAPH ?versionHistoryGraph { 18 | # parameters 19 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 20 | ( zbwext:Thsys undef undef "en" ) 21 | } 22 | # get the current and the previous version as default versions 23 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 24 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 25 | # select the versions to actually use 26 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 27 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 28 | # get the delta and via that the relevant graphs 29 | ?delta a sh:SchemeDelta ; 30 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 31 | sh:deltaTo/dc:identifier ?newVersionSelected ; 32 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 33 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 34 | dcterms:hasPart ?insertions ; 35 | dcterms:hasPart ?deletions . 36 | ?deletions a sh:SchemeDeltaDeletions ; 37 | sh:usingNamedGraph/sd:name ?deletionsGraph . 38 | ?insertions a sh:SchemeDeltaInsertions ; 39 | sh:usingNamedGraph/sd:name ?insertionsGraph . 40 | } 41 | # get deleted concept/notations 42 | GRAPH ?deletionsGraph { 43 | ?concept skos:notation ?oldNotation . 44 | } 45 | # ... which have been re-inserted with another notation 46 | GRAPH ?insertionsGraph { 47 | ?concept skos:notation ?newNotation . 48 | } 49 | # get additional information 50 | GRAPH ?oldVersionGraph { 51 | ?concept skos:prefLabel ?oldPrefLabel . 52 | } 53 | GRAPH ?newVersionGraph { 54 | ?concept skos:prefLabel ?newPrefLabel . 55 | } 56 | # create links to the RDFa pages of the different versions 57 | BIND (uri(concat("http://zbw.eu/stw/versions/", ?oldVersion, "/", substr(str(?concept), 19), "/about")) AS ?old) 58 | BIND (uri(concat("http://zbw.eu/stw/versions/", ?newVersion, "/", substr(str(?concept), 19), "/about")) AS ?new) 59 | # 60 | FILTER (lang(?oldPrefLabel) = ?language) 61 | FILTER (lang(?newPrefLabel) = ?language) 62 | } 63 | ORDER BY ?oldPrefLabel 64 | -------------------------------------------------------------------------------- /sparql/stw/changed_preferred_labels.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # Show concepts where the preferred label changed, and link to RDFa pages accordingly 12 | # 13 | SELECT DISTINCT ?old (str(?oldPrefLabel) AS ?oldLabel) (str(?newPrefLabel) AS ?newLabel) ?new 14 | WHERE { 15 | GRAPH ?versionHistoryGraph { 16 | # parameters 17 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 18 | ( zbwext:Descriptor undef undef "en" ) 19 | } 20 | # get the current and the previous version as default versions 21 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 22 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 23 | # select the versions to actually use 24 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 25 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 26 | # get the delta and via that the relevant graphs 27 | ?delta a sh:SchemeDelta ; 28 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 29 | sh:deltaTo/dc:identifier ?newVersionSelected ; 30 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 31 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 32 | dcterms:hasPart ?insertions ; 33 | dcterms:hasPart ?deletions . 34 | ?deletions a sh:SchemeDeltaDeletions ; 35 | sh:usingNamedGraph/sd:name ?deletionsGraph . 36 | ?insertions a sh:SchemeDeltaInsertions ; 37 | sh:usingNamedGraph/sd:name ?insertionsGraph . 38 | } 39 | # get deleted concept/prefLabel 40 | GRAPH ?deletionsGraph { 41 | ?concept skos:prefLabel ?oldPrefLabel . 42 | } 43 | # ... which have been re-inserted with another prefLabel 44 | GRAPH ?insertionsGraph { 45 | ?concept skos:prefLabel ?newPrefLabel . 46 | } 47 | # restrict by conceptType 48 | # (no variant for type URI since newVersion 8.06) 49 | GRAPH ?newVersionGraph { 50 | ?concept a ?conceptType . 51 | } 52 | # create links to the RDFa pages of the different versions 53 | BIND (uri(concat("http://zbw.eu/stw/versions/", ?oldVersionSelected, "/", substr(str(?concept), 19), "/about")) AS ?old) 54 | BIND (uri(concat("http://zbw.eu/stw/versions/", ?newVersionSelected, "/", substr(str(?concept), 19), "/about")) AS ?new) 55 | # 56 | FILTER (lang(?oldPrefLabel) = ?language) 57 | FILTER (lang(?newPrefLabel) = ?language) 58 | # 59 | # remove captialization-only changes 60 | FILTER ( lcase(?oldPrefLabel) != lcase(?newPrefLabel) ) 61 | } 62 | ORDER BY ?oldPrefLabel 63 | -------------------------------------------------------------------------------- /sparql/stw/count_added_concepts.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX skosxl: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # count concepts inserted per version 12 | # 13 | # (additional type skos:Concept introduced in 8.08) 14 | # 15 | SELECT ?version (str(count(distinct ?concept)) as ?addedConceptCount) 16 | WHERE { 17 | GRAPH ?versionHistoryGraph { 18 | # parameters 19 | VALUES ( ?versionHistoryGraph ?conceptType ) { 20 | ( zbwext:Descriptor ) 21 | } 22 | ?delta a sh:SchemeDelta ; 23 | sh:deltaTo ?newVHR ; 24 | sh:deltaFrom ?oldVHR ; 25 | dcterms:hasPart ?insertions ; 26 | dcterms:hasPart ?deletions . 27 | ?newVHR xhv:prev ?oldVHR ; 28 | dc:identifier ?version . 29 | ?oldVHR sh:usingNamedGraph/sd:name ?oldVersionGraph . 30 | ?insertions a sh:SchemeDeltaInsertions ; 31 | sh:usingNamedGraph/sd:name ?insertionsGraph . 32 | ?deletions a sh:SchemeDeltaDeletions ; 33 | sh:usingNamedGraph/sd:name ?deletionsGraph . 34 | } 35 | # for each inserted concept, a (newly inserted) prefLabel must exist ... 36 | GRAPH ?insertionsGraph { 37 | ?concept skosxl:prefLabel|skos:prefLabel ?prefLabel 38 | } 39 | # ... which did not exist in the old version 40 | FILTER NOT EXISTS { 41 | GRAPH ?oldVersionGraph { 42 | ?concept ?p [] 43 | } 44 | } 45 | # filter on concept type 46 | GRAPH ?versionGraph { 47 | ?concept a ?conceptType . 48 | } 49 | } 50 | GROUP BY ?version 51 | ORDER BY ?version 52 | -------------------------------------------------------------------------------- /sparql/stw/count_added_concepts_by_category.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX xhv: 8 | PREFIX zbwext: 9 | # 10 | # Identify concepts inserted with a certain version, 11 | # ordered by the second level subject category. 12 | # 13 | # Subject categories have a different concept type (subclass of 14 | # skos:Concept) and form mono-hierarchies within STW. The top 15 | # level subject categories are the sub-thesauri. A descriptor 16 | # often belongs to more than one subject category. 17 | # 18 | SELECT distinct ?secondLevelCategory (str(max(?secondLevelLabel)) AS ?secondLevelCategoryLabel) 19 | (str(count(distinct ?concept)) as ?addedConcepts) 20 | WHERE { 21 | GRAPH ?versionHistoryGraph { 22 | # parameters 23 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 24 | ( zbwext:Descriptor undef undef "en" ) 25 | } 26 | # get the current and the previous version as default versions 27 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 28 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 29 | # select the versions to actually use 30 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 31 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 32 | # get the delta and via that the relevant graphs 33 | ?delta a sh:SchemeDelta ; 34 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 35 | sh:deltaTo/dc:identifier ?newVersionSelected ; 36 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 37 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 38 | dcterms:hasPart ?insertions ; 39 | dcterms:hasPart ?deletions . 40 | ?deletions a sh:SchemeDeltaDeletions ; 41 | sh:usingNamedGraph/sd:name ?deletionsGraph . 42 | ?insertions a sh:SchemeDeltaInsertions ; 43 | sh:usingNamedGraph/sd:name ?insertionsGraph . 44 | } 45 | # for each inserted concept, a (newly inserted) prefLabel must exist ... 46 | GRAPH ?insertionsGraph { 47 | ?concept skos:prefLabel ?prefLabel 48 | } 49 | # ... without any prefLabel deleted for this concept 50 | FILTER NOT EXISTS { 51 | GRAPH ?deletionsGraph { 52 | ?concept skos:prefLabel [] 53 | } 54 | } 55 | GRAPH ?newVersionGraph { 56 | # get the top subject category (concept of subclass Thsys) 57 | # subject categories form a mono-hierarchy within STW 58 | ?concept a ?conceptType ; 59 | skos:broader ?category . 60 | ?category a zbwext:Thsys ; 61 | skos:broader* ?topConcept . 62 | ?scheme skos:hasTopConcept ?topConcept . 63 | # 64 | # get the second level category 65 | ?topConcept skos:narrower ?secondLevelCategory . 66 | ?category skos:broader* ?secondLevelCategory . 67 | # 68 | # get the label of the second level category 69 | ?secondLevelCategory skos:prefLabel ?secondLevelLabel 70 | } 71 | FILTER (lang(?secondLevelLabel) = ?language) 72 | } 73 | GROUP BY ?secondLevelCategory 74 | ORDER BY ?secondLevelCategoryLabel 75 | -------------------------------------------------------------------------------- /sparql/stw/count_added_concepts_by_category_all.rq: -------------------------------------------------------------------------------- 1 | # Identify concepts inserted with a certain version, 2 | # ordered by the subject category (of all levels). 3 | # 4 | PREFIX dc: 5 | PREFIX dcterms: 6 | PREFIX dsv: 7 | PREFIX sd: 8 | PREFIX sh: 9 | PREFIX skos: 10 | PREFIX xhv: 11 | PREFIX zbwext: 12 | # 13 | # Subject categories have a different concept type (subclass of 14 | # skos:Concept) and form mono-hierarchies within STW. The top 15 | # level subject categories are the sub-thesauri. A descriptor 16 | # often belongs to more than one subject category. 17 | # 18 | SELECT distinct ?category ?categoryLabel 19 | (str(count(distinct ?concept)) as ?addedConcepts) 20 | WHERE { 21 | GRAPH ?versionHistoryGraph { 22 | # parameters 23 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 24 | ( zbwext:Descriptor undef undef "en" ) 25 | } 26 | # get the current and the previous version as default versions 27 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 28 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 29 | # select the versions to actually use 30 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 31 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 32 | # get the delta and via that the relevant graphs 33 | ?delta a sh:SchemeDelta ; 34 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 35 | sh:deltaTo/dc:identifier ?newVersionSelected ; 36 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 37 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 38 | dcterms:hasPart ?insertions ; 39 | dcterms:hasPart ?deletions . 40 | ?deletions a sh:SchemeDeltaDeletions ; 41 | sh:usingNamedGraph/sd:name ?deletionsGraph . 42 | ?insertions a sh:SchemeDeltaInsertions ; 43 | sh:usingNamedGraph/sd:name ?insertionsGraph . 44 | } 45 | # for each inserted concept, a (newly inserted) prefLabel must exist ... 46 | GRAPH ?insertionsGraph { 47 | ?concept skos:prefLabel ?prefLabel 48 | } 49 | # ... without any prefLabel deleted for this concept 50 | FILTER NOT EXISTS { 51 | GRAPH ?deletionsGraph { 52 | ?concept skos:prefLabel [] 53 | } 54 | } 55 | GRAPH ?newVersionGraph { 56 | # get the top subject category (concept of subclass Thsys) 57 | # subject categories form a mono-hierarchy within STW 58 | ?concept a ?conceptType ; 59 | skos:broader ?category . 60 | ?category a zbwext:Thsys ; 61 | skos:prefLabel ?categoryLabel . 62 | 63 | } 64 | FILTER (lang(?categoryLabel) = ?language) 65 | } 66 | GROUP BY ?category ?categoryLabel 67 | ORDER BY ?categoryLabel 68 | -------------------------------------------------------------------------------- /sparql/stw/count_added_concepts_by_top.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX xhv: 8 | PREFIX zbwext: 9 | # 10 | # Count concepts inserted with a certain version, 11 | # by the topConcept (sub-thesaurus). 12 | # 13 | # Subject categories have a different concept type (subclass of 14 | # skos:Concept) and form mono-hierarchies within STW. The top 15 | # level subject categories are the sub-thesauri. A descriptor 16 | # often belongs to more than one subject category. 17 | # 18 | SELECT distinct ?topConcept (str(max(?topLabel)) AS ?topConceptLabel) 19 | (str(count(distinct ?concept)) as ?addedConcepts) 20 | WHERE { 21 | GRAPH ?versionHistoryGraph { 22 | # parameters 23 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 24 | ( zbwext:Descriptor undef undef "en" ) 25 | } 26 | # get the current and the previous version as default versions 27 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 28 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 29 | # select the versions to actually use 30 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 31 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 32 | # get the delta and via that the relevant graphs 33 | ?delta a sh:SchemeDelta ; 34 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 35 | sh:deltaTo/dc:identifier ?newVersionSelected ; 36 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 37 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 38 | dcterms:hasPart ?insertions ; 39 | dcterms:hasPart ?deletions . 40 | ?deletions a sh:SchemeDeltaDeletions ; 41 | sh:usingNamedGraph/sd:name ?deletionsGraph . 42 | ?insertions a sh:SchemeDeltaInsertions ; 43 | sh:usingNamedGraph/sd:name ?insertionsGraph . 44 | } 45 | # for each inserted concept, a (newly inserted) prefLabel must exist ... 46 | GRAPH ?insertionsGraph { 47 | ?concept skos:prefLabel ?prefLabel 48 | } 49 | # ... without any prefLabel deleted for this concept 50 | FILTER NOT EXISTS { 51 | GRAPH ?deletionsGraph { 52 | ?concept skos:prefLabel [] 53 | } 54 | } 55 | GRAPH ?newVersionGraph { 56 | # get the top subject category (concept of subclass Thsys) 57 | # subject categories form a mono-hierarchy within STW 58 | ?concept a ?conceptType ; 59 | skos:broader ?category . 60 | ?category a zbwext:Thsys ; 61 | skos:broader* ?topConcept . 62 | $scheme skos:hasTopConcept ?topConcept . 63 | ?topConcept skos:prefLabel ?topLabel . 64 | # 65 | } 66 | FILTER (lang(?topLabel) = ?language) 67 | } 68 | GROUP BY ?topConcept 69 | ORDER BY ?topConceptLabel 70 | -------------------------------------------------------------------------------- /sparql/stw/count_added_labels.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX xhv: 8 | PREFIX zbwext: 9 | # 10 | # Count added labels in a certain language per version 11 | # 12 | SELECT ?version (str(count(distinct ?label)) AS ?addedLabelCount) 13 | WHERE { 14 | GRAPH ?versionHistoryGraph { 15 | # parameters 16 | VALUES ( ?versionHistoryGraph ?conceptType ?language ) { 17 | ( zbwext:Descriptor "en" ) 18 | } 19 | ?delta a sh:SchemeDelta ; 20 | sh:deltaTo/dc:identifier ?version ; 21 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 22 | dcterms:hasPart ?insertions ; 23 | dcterms:hasPart ?deletions . 24 | ?insertions a sh:SchemeDeltaInsertions ; 25 | sh:usingNamedGraph/sd:name ?insertionsGraph . 26 | ?deletions a sh:SchemeDeltaDeletions ; 27 | sh:usingNamedGraph/sd:name ?deletionsGraph . 28 | } 29 | # for each inserted label ... 30 | GRAPH ?insertionsGraph { 31 | [] skos:prefLabel | skos:altLabel ?label 32 | } 33 | # ... which was not attached to some (other) concept before 34 | FILTER NOT EXISTS { 35 | GRAPH ?deletionsGraph { 36 | [] skos:prefLabel | skos:altLabel ?label 37 | } 38 | } 39 | FILTER (lang(?label) = ?language) 40 | # filter on concept type 41 | GRAPH ?newVersionGraph { 42 | ?concept skos:prefLabel | skos:altLabel ?label . 43 | ?concept a ?conceptType . 44 | } 45 | } 46 | GROUP BY ?version 47 | ORDER BY ?version 48 | -------------------------------------------------------------------------------- /sparql/stw/count_concepts.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dsv: 3 | PREFIX owl: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX zbwext: 7 | # 8 | # Count concepts of a certain type 9 | # 10 | SELECT ?version (str(count(?concept)) as ?conceptCount) 11 | WHERE { 12 | # parameters 13 | VALUES ( ?versionHistoryGraph ?type ) { 14 | ( "Descriptor" ) 15 | } 16 | GRAPH ?versionHistoryGraph { 17 | ?vhr dsv:hasVersionHistorySet ?vhs . 18 | ?vhr dc:identifier ?version . 19 | ?vhr sh:usingNamedGraph/sd:name ?versionGraph . 20 | } 21 | GRAPH ?versionGraph { 22 | # STW 8.04 used a different custom namespace URI 23 | BIND (uri(concat("http://zbw.eu/namespaces/skos-extensions/", ?type)) as ?oldConceptType) 24 | BIND (uri(concat("http://zbw.eu/namespaces/zbw-extensions/", ?type)) as ?conceptType) 25 | { 26 | ?concept a ?oldConceptType 27 | } UNION { 28 | ?concept a ?conceptType 29 | } 30 | FILTER NOT EXISTS { 31 | ?concept owl:deprecated true 32 | } 33 | } 34 | } 35 | GROUP BY ?version 36 | ORDER BY ?version 37 | -------------------------------------------------------------------------------- /sparql/stw/count_deleted_labels.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX xhv: 8 | PREFIX zbwext: 9 | # 10 | # Count deleted labels in a certain language per version 11 | # 12 | SELECT ?version (str(count(distinct ?label)) as ?deletedLabelCount) 13 | WHERE { 14 | GRAPH ?versionHistoryGraph { 15 | # parameters 16 | VALUES ( ?versionHistoryGraph ?type ?language ) { 17 | ( "Descriptor" "de" ) 18 | } 19 | ?delta a sh:SchemeDelta ; 20 | sh:deltaTo/dc:identifier ?version ; 21 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 22 | dcterms:hasPart ?insertions ; 23 | dcterms:hasPart ?deletions . 24 | ?insertions a sh:SchemeDeltaInsertions ; 25 | sh:usingNamedGraph/sd:name ?insertionsGraph . 26 | ?deletions a sh:SchemeDeltaDeletions ; 27 | sh:usingNamedGraph/sd:name ?deletionsGraph . 28 | } 29 | # for each deleted label ... 30 | GRAPH ?deletionsGraph { 31 | [] skos:prefLabel | skos:altLabel ?label 32 | } 33 | # ... without being inserted otherwise (for another concept or property) 34 | FILTER NOT EXISTS { 35 | GRAPH ?insertionsGraph { 36 | [] skos:prefLabel | skos:altLabel ?label 37 | } 38 | } 39 | FILTER (lang(?label) = ?language) 40 | # filter on concept type 41 | GRAPH ?oldVersionGraph { 42 | ?concept skos:prefLabel | skos:altLabel ?label . 43 | # STW 8.04 used a different custom namespace URI 44 | BIND (uri(concat("http://zbw.eu/namespaces/skos-extensions/", ?type)) as ?oldConceptType) 45 | BIND (uri(concat("http://zbw.eu/namespaces/zbw-extensions/", ?type)) as ?conceptType) 46 | { 47 | ?concept a ?oldConceptType 48 | } UNION { 49 | ?concept a ?conceptType 50 | } 51 | } 52 | } 53 | GROUP BY ?version 54 | ORDER BY ?version 55 | -------------------------------------------------------------------------------- /sparql/stw/count_deprecated_concepts.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # count deprecated concepts per version 12 | # 13 | SELECT ?version (str(count(?concept)) as ?deprecatedConceptCount) (str(count(?replacedByConcept)) as ?replacedByConceptCount) 14 | WHERE { 15 | # parameters (currently does not work on conceptType zbwext:Thsys) 16 | VALUES ( ?versionHistoryGraph ?conceptType ) { 17 | ( zbwext:Descriptor ) 18 | } 19 | GRAPH ?versionHistoryGraph { 20 | ?delta a sh:SchemeDelta ; 21 | sh:deltaTo ?newVHR ; 22 | sh:deltaFrom ?oldVHR ; 23 | dcterms:hasPart ?insertions ; 24 | dcterms:hasPart ?deletions . 25 | ?newVHR xhv:prev ?oldVHR ; 26 | dc:identifier ?version ; 27 | sh:usingNamedGraph/sd:name ?versionGraph . 28 | ?oldVHR sh:usingNamedGraph/sd:name ?oldVersionGraph . 29 | ?insertions a sh:SchemeDeltaInsertions ; 30 | sh:usingNamedGraph/sd:name ?insertionsGraph . 31 | ?deletions a sh:SchemeDeltaDeletions ; 32 | sh:usingNamedGraph/sd:name ?deletionsGraph . 33 | } 34 | # identify the deprecated concepts 35 | GRAPH ?insertionsGraph { 36 | ?concept owl:deprecated true 37 | } 38 | # filter on concept type 39 | GRAPH ?versionGraph { 40 | ?concept a ?conceptType . 41 | OPTIONAL { 42 | ?concept dcterms:isReplacedBy ?replacedByConcept 43 | } 44 | } 45 | } 46 | GROUP BY ?version 47 | ORDER BY ?version 48 | -------------------------------------------------------------------------------- /sparql/stw/count_deprecated_concepts_by_category.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # Count concepts deprecated with a certain version 12 | # by the second level subject category (of the new version!). 13 | # 14 | # Subject categories have a different concept type (subclass of 15 | # skos:Concept) and form mono-hierarchies within STW. The top 16 | # level subject categories are the sub-thesauri. A descriptor 17 | # often belongs to more than one subject category. 18 | # 19 | SELECT distinct ?secondLevelCategory (str(max(?secondLevelLabel)) AS ?secondLevelCategoryLabel) 20 | (str(count(distinct ?concept)) as ?deprecatedConcepts) 21 | WHERE { 22 | GRAPH ?versionHistoryGraph { 23 | # parameters 24 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 25 | ( zbwext:Descriptor undef undef "en" ) 26 | } 27 | # get the current and the previous version as default versions 28 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 29 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 30 | # select the versions to actually use 31 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 32 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 33 | # get the delta and via that the relevant graphs 34 | ?delta a sh:SchemeDelta ; 35 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 36 | sh:deltaTo/dc:identifier ?newVersionSelected ; 37 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 38 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 39 | dcterms:hasPart ?insertions ; 40 | dcterms:hasPart ?deletions . 41 | ?deletions a sh:SchemeDeltaDeletions ; 42 | sh:usingNamedGraph/sd:name ?deletionsGraph . 43 | ?insertions a sh:SchemeDeltaInsertions ; 44 | sh:usingNamedGraph/sd:name ?insertionsGraph . 45 | } 46 | # identify the deprecated concepts 47 | GRAPH ?insertionsGraph { 48 | ?concept owl:deprecated true 49 | } 50 | # Compute, for each level of the old hiearchy, the concepts 51 | # which got deprecated beyond that category 52 | GRAPH ?oldVersionGraph { 53 | # ugly fix for a different custom namespace URI used in STW 8.04 54 | BIND (uri(replace(str(?conceptType), "zbw-extensions", "skos-extensions")) AS ?obsoleteConceptType) 55 | BIND (uri(replace(str(zbwext:Thsys), "zbw-extensions", "skos-extensions")) AS ?obsoleteThsys) 56 | { 57 | ?concept a ?obsoleteConceptType 58 | } UNION { 59 | ?concept a ?conceptType 60 | } 61 | ?concept skos:broader ?category . 62 | { 63 | ?category a ?obsoleteThsys 64 | } UNION { 65 | ?category a zbwext:Thsys 66 | } 67 | } 68 | # Aggregate according to the hierarchy of the new (!) version 69 | GRAPH ?newVersionGraph { 70 | # get the top subject category (concept of subclass Thsys) 71 | # subject categories form a mono-hierarchy within STW 72 | ?scheme skos:hasTopConcept ?topConcept . 73 | # 74 | # get the second level category 75 | ?topConcept skos:narrower ?secondLevelCategory . 76 | ?category a zbwext:Thsys ; 77 | skos:broader* ?secondLevelCategory . 78 | # 79 | # get the label of the second level category 80 | ?secondLevelCategory skos:prefLabel ?secondLevelLabel 81 | } 82 | FILTER (lang(?secondLevelLabel) = ?language) 83 | } 84 | GROUP BY ?secondLevelCategory 85 | ORDER BY ?secondLevelCategoryLabel 86 | -------------------------------------------------------------------------------- /sparql/stw/count_deprecated_concepts_by_top.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # Count concepts deprecated with a certain version 12 | # by sub-thesaurus (skos:topConcept) 13 | # 14 | # Subject categories have a different concept type (subclass of 15 | # skos:Concept) and form mono-hierarchies within STW. The top 16 | # level subject categories are the sub-thesauri. A descriptor 17 | # often belongs to more than one subject category. 18 | # 19 | SELECT distinct ?topConcept (str(max(?topLabel)) AS ?topConceptLabel) 20 | (str(count(distinct ?concept)) as ?deprecatedConcepts) 21 | WHERE { 22 | GRAPH ?versionHistoryGraph { 23 | # parameters 24 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 25 | ( zbwext:Descriptor undef undef "en" ) 26 | } 27 | # get the current and the previous version as default versions 28 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 29 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 30 | # select the versions to actually use 31 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 32 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 33 | # get the delta and via that the relevant graphs 34 | ?delta a sh:SchemeDelta ; 35 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 36 | sh:deltaTo/dc:identifier ?newVersionSelected ; 37 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 38 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 39 | dcterms:hasPart ?insertions ; 40 | dcterms:hasPart ?deletions . 41 | ?deletions a sh:SchemeDeltaDeletions ; 42 | sh:usingNamedGraph/sd:name ?deletionsGraph . 43 | ?insertions a sh:SchemeDeltaInsertions ; 44 | sh:usingNamedGraph/sd:name ?insertionsGraph . 45 | } 46 | # identify the deprecated concepts 47 | GRAPH ?insertionsGraph { 48 | ?concept owl:deprecated true 49 | } 50 | GRAPH ?oldVersionGraph { 51 | # ugly fix for a different custom namespace URI used in STW 8.04 52 | BIND (uri(replace(str(?conceptType), "zbw-extensions", "skos-extensions")) AS ?obsoleteConceptType) 53 | BIND (uri(replace(str(zbwext:Thsys), "zbw-extensions", "skos-extensions")) AS ?obsoleteThsys) 54 | { 55 | ?concept a ?obsoleteConceptType 56 | } UNION { 57 | ?concept a ?conceptType 58 | } 59 | ?concept skos:broader ?category . 60 | { 61 | ?category a ?obsoleteThsys 62 | } UNION { 63 | ?category a zbwext:Thsys 64 | } 65 | ?category skos:broader* ?topConcept . 66 | ?scheme skos:hasTopConcept ?topConcept . 67 | } 68 | GRAPH ?newVersionGraph { 69 | ?topConcept skos:prefLabel ?topLabel 70 | } 71 | FILTER (lang(?topLabel) = ?language) 72 | } 73 | GROUP BY ?topConcept 74 | ORDER BY ?topConceptLabel 75 | -------------------------------------------------------------------------------- /sparql/stw/count_total_concepts_by_category.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX xhv: 8 | PREFIX zbwext: 9 | # 10 | # Identify concepts inserted with a certain version, 11 | # ordered by the second level subject category. 12 | # Subject categories have a different concept type (subclass of 13 | # skos:Concept) and form mono-hierarchies within STW. The top 14 | # level subject categories are the sub-thesauri. A descriptor 15 | # often belongs to more than one subject category. 16 | # 17 | SELECT distinct ?secondLevelCategory (str(max(?secondLevelLabel)) AS ?secondLevelCategoryLabel) 18 | (str(count(distinct ?concept)) as ?totalConcepts) 19 | WHERE { 20 | GRAPH ?versionHistoryGraph { 21 | # parameters 22 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 23 | ( zbwext:Descriptor undef undef "en" ) 24 | } 25 | # get the current version as default version 26 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 27 | # select the versions to actually use 28 | BIND(coalesce(?newVersion, ?latestVersion) AS ?versionSelected) 29 | # get the delta and via that the relevant graphs 30 | ?vhr a dsv:VersionHistoryRecord; 31 | dc:identifier $versionSelected ; 32 | sh:usingNamedGraph/sd:name ?versionGraph . 33 | } 34 | GRAPH ?versionGraph { 35 | ?scheme skos:hasTopConcept ?topConcept . 36 | ?topConcept skos:narrower ?secondLevelCategory . 37 | ?secondLevelCategory a zbwext:Thsys ; 38 | skos:prefLabel ?secondLevelLabel ; 39 | skos:narrower* ?category . 40 | ?category a zbwext:Thsys ; 41 | skos:narrower ?concept . 42 | ?concept a ?conceptType . 43 | } 44 | FILTER (lang(?secondLevelLabel) = ?language) 45 | } 46 | GROUP BY ?secondLevelCategory 47 | ORDER BY ?secondLevelCategoryLabel 48 | -------------------------------------------------------------------------------- /sparql/stw/count_total_concepts_by_top.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dsv: 3 | PREFIX owl: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX skos: 7 | PREFIX zbwext: 8 | # 9 | # Count concepts of a certain type 10 | # 11 | SELECT ?topConcept (str(max(?topLabel)) AS ?topConceptLabel) (str(count(?concept)) as ?totalConcepts) 12 | WHERE { 13 | GRAPH ?versionHistoryGraph { 14 | # parameters 15 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 16 | ( zbwext:Descriptor undef undef "en" ) 17 | } 18 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 19 | # select the version to actually use 20 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 21 | ?vhr dsv:hasVersionHistorySet ?vhs ; 22 | dc:identifier ?newVersionSelected ; 23 | sh:usingNamedGraph/sd:name ?versionGraph . 24 | } 25 | GRAPH ?versionGraph { 26 | # ugly fix for a different custom namespace URI used in STW 8.04 27 | BIND (uri(replace(str(?conceptType), "zbw-extensions", "skos-extensions")) AS ?obsoleteConceptType) 28 | { 29 | ?concept a ?obsoleteConceptType 30 | } UNION { 31 | ?concept a ?conceptType 32 | } 33 | FILTER NOT EXISTS { 34 | ?concept owl:deprecated true 35 | } 36 | # get the top subject category (concept of subclass Thsys) 37 | # subject categories form a mono-hierarchy within STW 38 | ?concept skos:broader ?category . 39 | ?category a zbwext:Thsys ; 40 | skos:broader* ?topConcept . 41 | $scheme skos:hasTopConcept ?topConcept . 42 | ?topConcept skos:prefLabel ?topLabel . 43 | # 44 | } 45 | FILTER (lang(?topLabel) = ?language) 46 | } 47 | GROUP BY ?topConcept 48 | ORDER BY ?topConceptLabel 49 | 50 | -------------------------------------------------------------------------------- /sparql/stw/deleted_labels.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # show all labels deleted in the current version 12 | # 13 | SELECT DISTINCT ?concept (str(?prefLabel) AS ?conceptLabel) (str(?label) AS ?deletedLabel) 14 | WHERE { 15 | GRAPH ?versionHistoryGraph { 16 | # parameters 17 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 18 | ( zbwext:Descriptor undef undef "en" ) 19 | } 20 | # get the current and the previous version as default versions 21 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 22 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 23 | # select the versions to actually use 24 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 25 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 26 | # get the delta and via that the relevant graphs 27 | ?delta a sh:SchemeDelta ; 28 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 29 | sh:deltaTo/dc:identifier ?newVersionSelected ; 30 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 31 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 32 | dcterms:hasPart ?insertions ; 33 | dcterms:hasPart ?deletions . 34 | ?deletions a sh:SchemeDeltaDeletions ; 35 | sh:usingNamedGraph/sd:name ?deletionsGraph . 36 | ?insertions a sh:SchemeDeltaInsertions ; 37 | sh:usingNamedGraph/sd:name ?insertionsGraph . 38 | } 39 | # get all deleted labels 40 | GRAPH ?deletionsGraph { 41 | [] skos:prefLabel | skos:altLabel ?label 42 | } 43 | # ... which were not attached to some (other) concept now 44 | FILTER NOT EXISTS { 45 | GRAPH ?insertionsGraph { 46 | [] skos:prefLabel | skos:altLabel | zbwext:altLabelNarrower | zbwext:altLabelRelated ?label 47 | } 48 | } 49 | FILTER (lang(?label) = ?language) 50 | # restrict to a certain concept type and get additional information 51 | GRAPH ?oldVersionGraph { 52 | ?concept skos:prefLabel | skos:altLabel ?label . 53 | # ugly fix for a different custom namespace URI used in STW 8.04 54 | # REMARK: Previously, we used a `UNION`+`BIND` construct here (see git 55 | # history). However, apparently using such a construct could introduce a 56 | # significant performance hit. 57 | # SeeAlso: https://stackoverflow.com/questions/43373293/sparql-bind-inside-union-is-too-slow 58 | values (?ct) { 59 | (zbwext:Descriptor) 60 | () 61 | } 62 | ?concept a ?ct 63 | } 64 | GRAPH ?newVersionGraph { 65 | ?concept skos:prefLabel ?prefLabel . 66 | } 67 | # restrict output to a certain language 68 | FILTER (lang(?prefLabel) = ?language) 69 | } 70 | ORDER BY ?label 71 | -------------------------------------------------------------------------------- /sparql/stw/deprecated_concepts_all.rq: -------------------------------------------------------------------------------- 1 | # List all deprecated concepts and (optionally) their replacements, 2 | # (workarround for the currently not working accross multiple versions 3 | # deprecated_concepts_by_category.rq) 4 | 5 | PREFIX skos: 6 | PREFIX owl: 7 | PREFIX rdf: 8 | PREFIX rdfs: 9 | PREFIX dcterms: 10 | prefix zbwext: 11 | prefix skosext: 12 | # 13 | SELECT ?concept (str(?label) as ?conceptLabel) ?replacement (str(?repLabel) as ?replacementLabel) 14 | WHERE { 15 | values ( ?graph ?conceptType ?language ) { 16 | ( undef zbwext:Descriptor "en" ) 17 | } 18 | graph ?graph { 19 | ?concept a ?conceptType ; 20 | owl:deprecated true . 21 | {?concept rdfs:label ?label } UNION {?concept skos:prefLabel ?label }. 22 | 23 | OPTIONAL { 24 | # replacements, which were later on replaced themselves, are not 25 | # shown, as they have no skos:prefLabel (by STW convention) 26 | ?concept dcterms:isReplacedBy ?replacement . 27 | ?replacement skos:prefLabel ?repLabel . 28 | } 29 | } 30 | filter (lang(?label) = ?language) 31 | optional { 32 | filter (lang(?repLabel) = ?language) 33 | } 34 | } 35 | ORDER BY ?label 36 | 37 | -------------------------------------------------------------------------------- /sparql/stw/deprecated_concepts_by_category.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # Identify descriptors deprecated with a certain version, 12 | # ordered by the subject categories (first and second level) 13 | # of the old version. 14 | # 15 | # Subject categories have a different concept type (subclass of 16 | # skos:Concept) and form mono-hierarchies within STW. The top 17 | # level subject categories are the sub-thesauri. A descriptor 18 | # often belongs to more than one subject category. 19 | # 20 | SELECT DISTINCT ?secondLevelCategory (str(?secondLevelLabel) AS ?secondLevelCategoryLabel) 21 | (?concept AS ?deprecatedConcept) (str(?prefLabel) AS ?deprecatedConceptLabel) 22 | (?replacedBy as ?replacedByConcept) (str(?replacedByPrefLabel) AS ?replacedByConceptLabel) 23 | WHERE { 24 | GRAPH ?versionHistoryGraph { 25 | # parameters 26 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 27 | ( zbwext:Descriptor undef undef "en" ) 28 | } 29 | # get the current and the previous version as default versions 30 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 31 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 32 | # select the versions to actually use 33 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 34 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 35 | # get the delta and via that the relevant graphs 36 | ?delta a sh:SchemeDelta ; 37 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 38 | sh:deltaTo/dc:identifier ?newVersionSelected ; 39 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 40 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 41 | dcterms:hasPart ?insertions ; 42 | dcterms:hasPart ?deletions . 43 | ?deletions a sh:SchemeDeltaDeletions ; 44 | sh:usingNamedGraph/sd:name ?deletionsGraph . 45 | ?insertions a sh:SchemeDeltaInsertions ; 46 | sh:usingNamedGraph/sd:name ?insertionsGraph . 47 | } 48 | # identify the deprecated concepts 49 | GRAPH ?insertionsGraph { 50 | ?concept owl:deprecated true 51 | } 52 | # get the replacedBy information 53 | GRAPH ?newVersionGraph { 54 | # get concepts and restrict to conceptType 55 | # (no variant for type URI since newVersion 8.06) 56 | ?concept a ?conceptType . 57 | OPTIONAL { 58 | ?concept dcterms:isReplacedBy ?replacedBy . 59 | ?replacedBy skos:prefLabel ?replacedByPrefLabel . 60 | } 61 | } 62 | # get categories 63 | GRAPH ?oldVersionGraph { 64 | # get the top subject category (concept of subclass Thsys) 65 | # subject categories form a mono-hierarchy within STW 66 | ?concept skos:prefLabel ?prefLabel ; 67 | skos:broader ?category . 68 | ?category a zbwext:Thsys ; 69 | skos:broader* ?topCategory . 70 | $scheme skos:hasTopConcept $topCategory . 71 | # 72 | # get the second level category and it's label 73 | ?topCategory skos:narrower ?secondLevelCategory . 74 | ?category skos:broader* ?secondLevelCategory . 75 | ?secondLevelCategory skos:prefLabel ?secondLevelLabel . 76 | } 77 | FILTER (lang(?prefLabel) = ?language && lang(?secondLevelLabel) = ?language) 78 | FILTER (!bound(?replacedByPrefLabel) || lang(?replacedByPrefLabel) = ?language) 79 | } 80 | ORDER BY ?secondLevelCategoryLabel ?prefLabel 81 | 82 | -------------------------------------------------------------------------------- /sparql/stw/merged_partially.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # Partially merged deprecated concepts 12 | # 13 | SELECT DISTINCT (?oldConcept AS ?deprecatedConcept) (str(?oldPrefLabel) AS ?deprecatedConceptLabel) 14 | ?replacedByConcept (str(?replacedByLabel) AS ?replacedByConceptLabel) 15 | (str(?label) AS ?movedLabel) 16 | ?toConcept (str(?newPrefLabel) AS ?toConceptLabel) 17 | ?isNew 18 | WHERE { 19 | GRAPH ?versionHistoryGraph { 20 | # parameters 21 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 22 | ( zbwext:Descriptor undef undef "en" ) 23 | } 24 | # get the current and the previous version as default versions 25 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 26 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 27 | # select the versions to actually use 28 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 29 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 30 | # get the delta and via that the relevant graphs 31 | ?delta a sh:SchemeDelta ; 32 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 33 | sh:deltaTo/dc:identifier ?newVersionSelected ; 34 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 35 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 36 | dcterms:hasPart ?insertions ; 37 | dcterms:hasPart ?deletions . 38 | ?deletions a sh:SchemeDeltaDeletions ; 39 | sh:usingNamedGraph/sd:name ?deletionsGraph . 40 | ?insertions a sh:SchemeDeltaInsertions ; 41 | sh:usingNamedGraph/sd:name ?insertionsGraph . 42 | } 43 | # get deleted labels (in all languages) ... 44 | GRAPH ?deletionsGraph { 45 | ?oldConcept skos:prefLabel | skos:altLabel ?label ; 46 | ?oldLabelType ?label . 47 | } 48 | # ... which have been moved to another concept (or perhaps have got another labelType) 49 | GRAPH ?insertionsGraph { 50 | ?toConcept skos:prefLabel | skos:altLabel ?label . 51 | ?toConcept ?newLabelType ?label . 52 | } 53 | # restrict to a certain concept type and get additional information 54 | GRAPH ?oldVersionGraph { 55 | ?oldConcept skos:prefLabel | skos:altLabel ?label ; 56 | skos:prefLabel ?oldPrefLabel . 57 | # ugly fix for a different custom namespace URI used in STW 8.04 58 | # REMARK: Previously, we used a `UNION`+`BIND` construct here (see git 59 | # history). However, apparently using such a construct could introduce a 60 | # significant performance hit. 61 | # SeeAlso: https://stackoverflow.com/questions/43373293/sparql-bind-inside-union-is-too-slow 62 | values (?ct) { 63 | (zbwext:Descriptor) 64 | () 65 | } 66 | ?concept a ?ct 67 | } 68 | GRAPH ?newVersionGraph { 69 | ?oldConcept owl:deprecated ?deprecated . 70 | OPTIONAL { 71 | ?oldConcept dcterms:isReplacedBy ?replacedByConcept . 72 | ?replacedByConcept skos:prefLabel ?replacedByLabel . 73 | } 74 | # (no variant for type URI since newVersion 8.06) 75 | ?toConcept a ?conceptType ; 76 | skos:prefLabel | skos:altLabel ?label ; 77 | skos:prefLabel ?newPrefLabel . 78 | } 79 | # only look at concepts which are not completely merged 80 | FILTER (?toConcept != ?replacedByConcept) 81 | # flag new concepts which were newly introduced 82 | OPTIONAL { 83 | BIND (true AS ?isNew) 84 | FILTER not exists { 85 | GRAPH ?oldVersionGraph { 86 | ?toConcept ?p [] . 87 | } 88 | } 89 | } 90 | FILTER (lang(?label) = ?language 91 | && lang(?oldPrefLabel) = ?language 92 | && lang(?replacedByLabel) = ?language 93 | && lang(?newPrefLabel) = ?language ) 94 | } 95 | ORDER BY ?oldPrefLabel ?label 96 | -------------------------------------------------------------------------------- /sparql/stw/moved_categories_subthes.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # Identify categories which has been moved to another sub-thesaurus (topConcept) 12 | # 13 | SELECT distinct (str(?oldLabel) AS ?oldCategoryLabel) ?category (str(?newLabel) AS ?categoryLabel) 14 | WHERE { 15 | GRAPH ?versionHistoryGraph { 16 | # parameters 17 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 18 | ( zbwext:Descriptor undef undef "en" ) 19 | } 20 | # get the current and the previous version as default versions 21 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 22 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 23 | # select the versions to actually use 24 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 25 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 26 | # get the delta and via that the relevant graphs 27 | ?delta a sh:SchemeDelta ; 28 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 29 | sh:deltaTo/dc:identifier ?newVersionSelected ; 30 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 31 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 32 | dcterms:hasPart ?insertions ; 33 | dcterms:hasPart ?deletions . 34 | ?deletions a sh:SchemeDeltaDeletions ; 35 | sh:usingNamedGraph/sd:name ?deletionsGraph . 36 | ?insertions a sh:SchemeDeltaInsertions ; 37 | sh:usingNamedGraph/sd:name ?insertionsGraph . 38 | } 39 | # get all secondLevelConcepts from the old version 40 | GRAPH ?oldVersionGraph { 41 | ?scheme skos:hasTopConcept ?oldTopConcept . 42 | ?category a zbwext:Thsys ; 43 | skos:broader+ ?oldTopConcept ; 44 | skos:prefLabel ?oldLabel . 45 | } 46 | # identify categories with a different top concept 47 | GRAPH ?newVersionGraph { 48 | ?category skos:prefLabel ?newLabel ; 49 | skos:broader+ ?newTopConcept . 50 | ?scheme skos:hasTopConcept ?newTopConcept . 51 | } 52 | FILTER (?oldTopConcept != ?newTopConcept) 53 | FILTER (lang(?oldLabel) = ?language && lang(?newLabel) = ?language) 54 | } 55 | ORDER BY ?newLabel 56 | 57 | -------------------------------------------------------------------------------- /sparql/stw/moved_labels.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX owl: 5 | PREFIX sd: 6 | PREFIX sh: 7 | PREFIX skos: 8 | PREFIX xhv: 9 | PREFIX zbwext: 10 | # 11 | # show all labels which already existed in the previous version, 12 | # but were moved to another concept in the current one 13 | # 14 | SELECT DISTINCT (str(?label) AS ?movedLabel) ?oldLabelType ?oldConcept (str(?oldPrefLabel) as ?oldConceptLabel) ?isDeprecated 15 | ?newLabelType ?newConcept (str(?newPrefLabel) as ?newConceptLabel) 16 | WHERE { 17 | GRAPH ?versionHistoryGraph { 18 | # parameters 19 | VALUES ( ?versionHistoryGraph ?conceptType ?oldVersion ?newVersion ?language ) { 20 | ( zbwext:Descriptor undef undef "en" ) 21 | } 22 | # get the current and the previous version as default versions 23 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 24 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 25 | # select the versions to actually use 26 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 27 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 28 | # get the delta and via that the relevant graphs 29 | ?delta a sh:SchemeDelta ; 30 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 31 | sh:deltaTo/dc:identifier ?newVersionSelected ; 32 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 33 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 34 | dcterms:hasPart ?insertions ; 35 | dcterms:hasPart ?deletions . 36 | ?deletions a sh:SchemeDeltaDeletions ; 37 | sh:usingNamedGraph/sd:name ?deletionsGraph . 38 | ?insertions a sh:SchemeDeltaInsertions ; 39 | sh:usingNamedGraph/sd:name ?insertionsGraph . 40 | } 41 | # get deleted labels (in all languages) ... 42 | GRAPH ?deletionsGraph { 43 | ?oldConcept skos:prefLabel | skos:altLabel ?label . 44 | ?oldConcept ?oldLabelType ?label . 45 | } 46 | # ... which have been moved to another concept (or perhaps have got another labelType) 47 | GRAPH ?insertionsGraph { 48 | ?newConcept skos:prefLabel | skos:altLabel ?label . 49 | ?newConcept ?newLabelType ?label . 50 | } 51 | # restrict to a certain concept type and get additional information 52 | GRAPH ?oldVersionGraph { 53 | ?oldConcept skos:prefLabel | skos:altLabel ?label ; 54 | skos:prefLabel ?oldPrefLabel . 55 | # ugly fix for a different custom namespace URI used in STW 8.04 56 | BIND (uri(replace(str(?conceptType), "zbw-extensions", "skos-extensions")) AS ?obsoleteConceptType) 57 | { 58 | ?oldConcept a ?obsoleteConceptType 59 | } UNION { 60 | ?oldConcept a ?conceptType 61 | } 62 | } 63 | GRAPH ?newVersionGraph { 64 | ?newConcept skos:prefLabel | skos:altLabel ?label . 65 | ?newConcept a ?conceptType . 66 | ?newConcept skos:prefLabel ?newPrefLabel . 67 | } 68 | OPTIONAL { 69 | GRAPH ?newVersionGraph { 70 | ?oldConcept owl:deprecated true . 71 | ?oldConcept owl:deprecated ?deprecated . 72 | BIND(if(?deprecated = true, true, '') as ?isDeprecated) 73 | } 74 | } 75 | FILTER (lang(?label) = ?language 76 | && lang(?newPrefLabel) = ?language 77 | && lang(?oldPrefLabel) = ?language) 78 | } 79 | ORDER BY ?oldPrefLabel ?label 80 | -------------------------------------------------------------------------------- /sparql/swdskos/README.md: -------------------------------------------------------------------------------- 1 | GND subject headings as SKOS vocabulary 2 | ========================= 3 | 4 | The data for this very experimental application is extracted from the [GND Linked Data Service](http://www.dnb.de/EN/Service/DigitaleDienste/LinkedData/linkeddata_node.html), a dump of the German Integrated Authority File. It was restricted to the gndo:SubjectHeadingSensoStricto type, transformed to SKOS (via a [construct query](https://github.com/jneubert/sparql-queries/blob/master/gnd/construct_as_skos.rq)) and complemented by the GND [subject categories](http://d-nb.info/standards/vocab/gnd/gnd-sc). 5 | 6 | The vocabulary comprises 134.000 concepts, organized by 450 subject categories. 7 | 8 | __Queries__ 9 | 10 | Query | Description 11 | ------|------------ 12 | [added_concepts_by_category](http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/swdskos/added_concepts_by_category.rq&endpoint=http://zbw.eu/beta/sparql/swdskosv/query&versionHistoryGraph=http://zbw.eu/beta/swdskos/version&language=de) | Added GND concepts by subject category 13 | 14 | -------------------------------------------------------------------------------- /sparql/swdskos/added_concepts_by_category.rq: -------------------------------------------------------------------------------- 1 | # Identify concepts inserted with a certain version, listed by subject category 2 | # 3 | PREFIX dc: 4 | PREFIX dcterms: 5 | PREFIX dsv: 6 | PREFIX gndo: 7 | PREFIX sd: 8 | PREFIX sh: 9 | PREFIX skos: 10 | PREFIX skosxl: 11 | PREFIX xhv: 12 | # 13 | SELECT distinct ?notation ?category (str(?catLabel) as ?categoryLabel) (?concept AS ?addedConcept) (str(?prefLabel) AS ?addedConceptLabel) 14 | #SELECT distinct ?notation (str(?catLabel) as ?categoryLabel) (?concept AS ?addedConcept) (str(?prefLabel) AS ?addedConceptLabel) 15 | WHERE { 16 | GRAPH ?versionHistoryGraph { 17 | # parameters 18 | VALUES ( ?versionHistoryGraph ?oldVersion ?newVersion ?language ) { 19 | ( undef undef "de" ) 20 | } 21 | # get the current and the previous version as default versions 22 | ?versionset dsv:currentVersionRecord/xhv:prev/dc:identifier ?previousVersion . 23 | ?versionset dsv:currentVersionRecord/dc:identifier ?latestVersion . 24 | # select the versions to actually use 25 | BIND(coalesce(?oldVersion, ?previousVersion) AS ?oldVersionSelected) 26 | BIND(coalesce(?newVersion, ?latestVersion) AS ?newVersionSelected) 27 | # get the delta and via that the relevant graphs 28 | ?delta a sh:SchemeDelta ; 29 | sh:deltaFrom/dc:identifier ?oldVersionSelected ; 30 | sh:deltaTo/dc:identifier ?newVersionSelected ; 31 | sh:deltaFrom/sh:usingNamedGraph/sd:name ?oldVersionGraph ; 32 | sh:deltaTo/sh:usingNamedGraph/sd:name ?newVersionGraph ; 33 | dcterms:hasPart ?insertions ; 34 | dcterms:hasPart ?deletions . 35 | ?insertions a sh:SchemeDeltaInsertions ; 36 | sh:usingNamedGraph/sd:name ?insertionsGraph . 37 | ?deletions a sh:SchemeDeltaDeletions ; 38 | sh:usingNamedGraph/sd:name ?deletionsGraph . 39 | } 40 | # for each inserted concept, a newly inserted prefLabel must exist ... 41 | GRAPH ?insertionsGraph { 42 | ?concept skosxl:prefLabel/skosxl:literalForm | skos:prefLabel ?prefLabel ; 43 | gndo:gndSubjectCategory ?category 44 | . 45 | } 46 | # ... and the concept must not exist in the old version 47 | FILTER NOT EXISTS { 48 | GRAPH ?oldVersionGraph { 49 | ?concept ?p [] 50 | } 51 | } 52 | GRAPH ?newVersionGraph { 53 | ?category skos:prefLabel ?catLabel ; 54 | skos:notation ?notation . 55 | } 56 | # restrict output to a certain language 57 | FILTER ( lang(?prefLabel) = ?language ) 58 | } 59 | ORDER BY ?category ?prefLabel 60 | 61 | -------------------------------------------------------------------------------- /sparql/version_graph.rq: -------------------------------------------------------------------------------- 1 | PREFIX dc: 2 | PREFIX dcterms: 3 | PREFIX dsv: 4 | PREFIX sd: 5 | PREFIX sh: 6 | PREFIX void: 7 | PREFIX xhv: 8 | PREFIX xsd: 9 | # 10 | # the complete version history graph 11 | # 12 | CONSTRUCT { 13 | ?s ?p ?o . 14 | } 15 | WHERE { 16 | # parameters 17 | VALUES ( ?versionHistoryGraph ) { 18 | ( undef ) 19 | } 20 | GRAPH ?versionHistoryGraph { 21 | # identify the graph via 22 | ?vhs dsv:currentVersionRecord [] . 23 | ?s ?p ?o 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /sparql/version_overview.rq: -------------------------------------------------------------------------------- 1 | # Discover the version history graph and all available scheme versions 2 | # 3 | PREFIX dc: 4 | PREFIX dsv: 5 | # 6 | SELECT ?versionHistoryGraph (?vhr AS ?versionHistoryRecord) (?identifier AS ?version) (str(?vhrDate) AS ?date) ?current 7 | WHERE { 8 | # parameters 9 | VALUES ( ?versionHistoryGraph ) { 10 | ( undef ) 11 | } 12 | GRAPH ?versionHistoryGraph { 13 | ?vhr dsv:hasVersionHistorySet ?vhs . 14 | ?vhr dc:date ?vhrDate . 15 | ?vhr dc:identifier ?identifier 16 | OPTIONAL { 17 | ?vhs dsv:currentVersionRecord ?current 18 | FILTER ( ?vhr = ?current ) 19 | } 20 | } 21 | } 22 | ORDER BY ?date 23 | --------------------------------------------------------------------------------