namespace/bin/prov-ns.sh
author Paul Groth <p.t.groth@vu.nl>
Fri, 07 Jun 2013 20:21:19 +0200
changeset 6412 600c6fd1fdb4
parent 6345 5a8e68980617
permissions -rwxr-xr-x
minor updates to address dong's comments
     1 #!/bin/bash
     2 #3> <> prov:wasAttributedTo <http://tw.rpi.edu/instances/TimLebo>,
     3 #3>                         <http://data.semanticweb.org/person/paul-groth>;
     4 #3>    rdfs:seeAlso <readme.md> .
     5 #
     6 # This script follows ../prov.owl as a template to produce a releasable concatenation at ../releases/$version/prov.owl.
     7 #
     8 # This script will materialize any prov:hadDerivation that appears in prov.owl, 
     9 # by fetching the OWL and Turtle versions that are hard-coded into this script (for Turtle) and in prov-ns.xsl (for RDF/XML).
    10 
    11    prev="prov-YYYYmmdd"
    12 version="prov-YYYYMMDD"
    13 
    14 if [ "$1" == "--help" ]; then
    15    echo "usage: `basename $0` [previous-version] [version]"
    16    echo
    17    echo "  previous-version e.g. prov-20121211 (default: $prev)"
    18    echo "           version e.g. prov-20130131 (default: $version)"
    19    exit
    20 elif [ $# -eq 2 ]; then
    21    prev=$1
    22    version=$2
    23 else
    24    echo
    25    echo "WARNING: using default version identifiers; see `basename $0` --help"
    26    echo
    27 fi
    28 
    29 HOME=$(cd ${0%/*} && echo ${PWD%/*})
    30 
    31 release=$HOME/releases/$version/prov.owl
    32 if [ ! -e `dirname $release` ]; then
    33    mkdir -p `dirname $release` 
    34 fi
    35 
    36 java -jar $HOME/lib/saxon9.jar $HOME/prov.owl $HOME/bin/prov-ns.xsl previous-version=$prev version=$version > $release
    37 
    38 echo
    39 release=${release##`pwd`/}
    40 echo $release
    41 #echo ${release}.ttl
    42 #rapper -q -g -o turtle $release > ${release}.ttl
    43 
    44 turtle=${release%.owl}.ttl
    45 echo $turtle
    46 echo "@prefix : <http://www.w3.org/ns/prov#> ."  > $turtle
    47 rapper -q -g -o turtle $HOME/prov.owl           >> $turtle
    48 perl -pi -e "s/prov-YYYYMMDD/$version/g"           $turtle
    49 perl -pi -e "s/prov-YYYYmmdd/$prev/g"              $turtle
    50 
    51 # $1: ontology URI
    52 # $2: ontology location
    53 function materialize_import { 
    54    #echo "$turtle += $1"
    55    echo "Including $1 from $2"
    56    echo                                         >> $turtle
    57    echo "# The following was imported from $1"  >> $turtle
    58    echo                                         >> $turtle
    59    curl -Ls $2 | grep -v "^@prefix"             >> $turtle
    60 } 
    61 
    62 # NOTE: These ontology-source mappings need to be stated in bin/prov-ns.xsl, too.
    63 materialize_import 'http://www.w3.org/ns/prov-o#'          https://dvcs.w3.org/hg/prov/raw-file/tip/namespace/prov-o.ttl
    64 materialize_import 'http://www.w3.org/ns/prov-o-inverses#' https://dvcs.w3.org/hg/prov/raw-file/tip/namespace/prov-o-inverses.ttl
    65 materialize_import 'http://www.w3.org/ns/prov-aq#'         https://dvcs.w3.org/hg/prov/raw-file/tip/namespace/prov-aq.ttl
    66 materialize_import 'http://www.w3.org/ns/prov-dc#'         https://dvcs.w3.org/hg/prov/raw-file/tip/namespace/prov-dc.ttl
    67 materialize_import 'http://www.w3.org/ns/prov-dictionary#' https://dvcs.w3.org/hg/prov/raw-file/tip/namespace/prov-dictionary.ttl
    68 materialize_import 'http://www.w3.org/ns/prov-links#'      https://dvcs.w3.org/hg/prov/raw-file/tip/namespace/prov-links.ttl
    69 
    70 #prov-o.ttl
    71 #prov-o-inverses.ttl
    72 #prov-aq.ttl
    73 #prov-dc.ttl
    74 #prov-dictionary.ttl
    75 #prov-links.ttl