Last active
June 4, 2019 20:42
-
-
Save ajnelson-nist/53a7c2772747a821f7798e93aaf78cc2 to your computer and use it in GitHub Desktop.
Test round-trip conversion of UCO ontology file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This software was developed at the National Institute of Standards | |
# and Technology by employees of the Federal Government in the course | |
# of their official duties. Pursuant to title 17 Section 105 of the | |
# United States Code this software is not subject to copyright | |
# protection and is in the public domain. NIST assumes no | |
# responsibility whatsoever for its use by other parties, and makes | |
# no guarantees, expressed or implied, about its quality, | |
# reliability, or any other characteristic. | |
# | |
# We would appreciate acknowledgement if the software is used. | |
# This script is provided for discussion purposes, and is expected to be | |
# revised (especially to change Git references). | |
# It tests a round-trip conversion between Turtle and RDF-XML, using | |
# rdf-toolkit. The file that it tests is the UCO core.ttl file. | |
# | |
# This script is also intentionally noisy (e.g. 'set -x'). | |
# | |
# Execution attempts to be idempotent w.r.t. the network. | |
# - If run in a directory where the 'UCO' subdirectory exists, a Git | |
# clone will not run. | |
# - If the 'rdf-toolkit.jar' file exists in that UCO directory, it will | |
# not be downloaded. | |
# | |
# Feedback is welcome. | |
# Usage: | |
# ./test.sh | |
# | |
# Output: | |
# Execution/debug information dumped to stderr. | |
# Exit status will be 0 on a successful test run. | |
set -x | |
set -e | |
set -u | |
# Guarantee UCO repository cloned. | |
if [ ! -d UCO ]; then | |
git clone \ | |
https://github.com/ucoProject/UCO | |
fi | |
# Descend into UCO directory to run test. | |
pushd UCO/uco-core | |
# Report Git branch (or commit) being inspected. | |
git log -n1 | |
# Guarantee rdf-toolkit.jar exists. | |
# Retrieval instructions c/o: | |
# https://github.com/edmcouncil/rdf-toolkit | |
if [ ! -r rdf-toolkit.jar ]; then | |
wget https://jenkins.edmcouncil.org/view/all/job/rdf-toolkit-build/lastSuccessfulBuild/artifact/target/scala-2.12/rdf-toolkit.jar | |
fi | |
# Report version of rdf-toolkit.jar. | |
java -jar rdf-toolkit.jar \ | |
--version | |
# 'Normalize' core.ttl to default output of rdf-toolkit. | |
java -jar rdf-toolkit.jar \ | |
--infer-base-iri \ | |
--inline-blank-nodes \ | |
--source core.ttl \ | |
--source-format turtle \ | |
--target core-normalized.ttl \ | |
--target-format turtle | |
# Translate 'normalized' Turtle to RDF-XML. | |
java -jar rdf-toolkit.jar \ | |
--infer-base-iri \ | |
--inline-blank-nodes \ | |
--source core-normalized.ttl \ | |
--source-format turtle \ | |
--target core-normalized.rdf \ | |
--target-format rdf-xml \ | |
--use-dtd-subset | |
# Translate RDF-XML back to 'normalized' Turtle. | |
java -jar rdf-toolkit.jar \ | |
--infer-base-iri \ | |
--inline-blank-nodes \ | |
--source core-normalized.rdf \ | |
--source-format rdf-xml \ | |
--target core-returned.ttl \ | |
--target-format turtle | |
# Use 'diff' to report any changes introduced in conversion. | |
# Recall that 'diff' exits non-0 if any differences found. | |
# Ideally, this command emits nothing and exits 0. | |
diff \ | |
core-normalized.ttl \ | |
core-returned.ttl | |
popd #UCO/uco-core |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment