diff options
author | Jonas Smedegaard <dr@jones.dk> | 2011-08-06 01:55:01 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2011-08-06 01:55:01 +0200 |
commit | 116cea991dd8b2df80968ca8c074d61c43367c25 (patch) | |
tree | 974eb2d65d4e84ebba4c8b52eae91ff7f1216a14 /foaf | |
parent | a71ff588fdc7286dbfada101ea7e3b8561402ad9 (diff) |
Add rdf2turtle.sh script to 'reverse-engineer' RDF files.
Diffstat (limited to 'foaf')
-rwxr-xr-x | foaf/rdf2turtle.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/foaf/rdf2turtle.sh b/foaf/rdf2turtle.sh new file mode 100755 index 0000000..676cd25 --- /dev/null +++ b/foaf/rdf2turtle.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +rdffile="$1" +ttlfile="${2:-$(basename "$rdffile" .rdf).ttl}" + +exit1() { + echo "ERROR: $1" + exit 1 +} + +[ -e "$rdffile" ] || exit1 "RDF file \"$rdffile\" does not exist." +[ ! -e "$ttlfile" ] || exit1 "Turtle file \"$ttlfile\" already exists." + +base="$(perl -ne '/\bxml:base="(http.+)"/ and print $1 and exit;' "$rdffile")" || true #' +rapper -i rdfxml ${base:+-O "$base"} -o turtle "$rdffile" > "$ttlfile" +perl -i -pe 's/ {4}/\t/g' "$ttlfile" |