-
Notifications
You must be signed in to change notification settings - Fork 0
/
tcf2rdf.sh
executable file
·52 lines (40 loc) · 883 Bytes
/
tcf2rdf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
outfile=/dev/stdout
format=turtle
rmlmapper_jar=$RMLMAPPER_JAR
usage () {
echo "$1"
cat <<EOF
USAGE: $0 [ -o OUTFILE ] [ -f FORMAT ] [ -j JAR ] TCF-FILE
-o send RDF output to OUTFILE; defaults to $outfile
-f any output format rmlmapper knows about; defaults to $format
-j path to rmlmapper jar
This is essentially a wrapper around rmlmapper.
EOF
exit $2
}
while (($# > 1)); do
case $1 in
-o)
outfile=$2
shift
shift
;;
-f)
format=$2
shift
shift
;;
-*)
usage "" 2
;;
esac
done
if [ $# -lt 1 ]; then usage "" 1; fi
[ -f $1 ] || usage "ERROR: '$1' no such file" 1
infile=$1
range=$(basename -s .tcf $infile)
rmlfile=$(mktemp)
sed "s#INPUT\.tcf#$infile#g; s#INPUT#$range#g" rml4tcf.ttl > $rmlfile
java -jar $rmlmapper_jar -s $format -m "$rmlfile" -o $outfile
rm $rmlfile