Skip to content

Commit 24d506a

Browse files
committed
add ld setup
1 parent 2aee946 commit 24d506a

File tree

5 files changed

+103
-0
lines changed

5 files changed

+103
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,23 @@ jobs:
140140
echo 'file unchanged, skipping.'
141141
fi;
142142
143+
- name: "Generate linked data: DE_ZHV"
144+
# todo: do not run if processing the dataset failed
145+
if: ${{ success() }} # this should allow the other steps to run, but should still mark the workflow as failing
146+
env:
147+
DO_SPACES_BUCKET_NAME: ${{ secrets.DO_SPACES_BUCKET_NAME }}
148+
run: |
149+
set -e;
150+
./src/linked-data/zhv-de/index.sh
151+
currentobj=$(aws s3api head-object --bucket $DO_SPACES_BUCKET_NAME --key de/zhv.ttl.gz || echo 'not-yet-existing');
152+
newhash=$(cat ./src/linked-data/zhv-de/data/output.ttl.gz | md5sum);
153+
if [ $(echo $currentobj | grep $newhash | wc -l) -ne 1 ]
154+
then
155+
aws s3 cp --acl public-read ./src/linked-data/zhv-de/data/output.ttl.gz s3://"$DO_SPACES_BUCKET_NAME"/de/zhv.ttl.gz
156+
else
157+
echo 'file unchanged, skipping.'
158+
fi;
159+
143160
- name: "Fetch and upload feed: DE_NRW_GTFS"
144161
if: ${{ success() || failure() }} # this should allow the other steps to run, but should still mark the workflow as failing
145162
env:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ shrinkwrap.yaml
1010
pnpm-lock.yaml
1111
dist
1212

13+
data
1314
*.zip

src/linked-data/.bin/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

src/linked-data/zhv-de/index.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
DIR=$(dirname "$0")
4+
BASE_IRI="https://lod.codefor.de/"
5+
BIN_DIR="$DIR/../.bin"
6+
DATA_DIR="$DIR/data"
7+
8+
echo 'Fetching rmlmapper'
9+
wget -q --show-progress --progress=dot:mega -c -N -O "$BIN_DIR/rmlmapper.jar" https://github.com/RMLio/rmlmapper-java/releases/download/v7.0.0/rmlmapper-7.0.0-r374-all.jar
10+
11+
rm -rf "$DATA_DIR"
12+
mkdir -p "$DATA_DIR"
13+
14+
echo 'Preparing data…'
15+
cp "$DIR/../../../de-zhv.zip" "$DATA_DIR/source.zip"
16+
unzip "$DATA_DIR/source.zip" -d "$DATA_DIR/unzipped"
17+
find "$DATA_DIR/unzipped/" -name "*.csv" -exec mv '{}' "$DATA_DIR/source.csv" \;
18+
19+
pnpx csvtojson --delimiter=";" "$DATA_DIR/source.csv" > "$DATA_DIR/source.json"
20+
21+
echo 'Applying mapping…'
22+
java -jar "$BIN_DIR/rmlmapper.jar" -m "$DIR/mapping.ttl" -s turtle --strict --base-iri "$BASE_IRI" > "$DATA_DIR/output.ttl"
23+
24+
echo 'Compressing output…'
25+
cat "$DATA_DIR/output.ttl" | gzip > "$DATA_DIR/output.ttl.gz"
26+
27+
# echo 'Done.'

src/linked-data/zhv-de/mapping.ttl

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
@prefix bahnhof: <https://lod.bahnhof.de/vocabulary/db/>.
2+
@prefix codeforde: <https://lod.codefor.de/vocabulary/codeforde/>.
3+
@prefix dct: <http://purl.org/dc/terms/>.
4+
@prefix dbo: <https://dbpedia.org/ontology/>.
5+
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
6+
@prefix geo: <http://www.opengis.net/ont/geosparql#>.
7+
@prefix gn: <http://www.geonames.org/ontology#>.
8+
@prefix juso: <http://rdfs.co/juso/>.
9+
@prefix netex: <https://lod.bahnhof.de/vocabulary/netex/>.
10+
@prefix owl: <http://www.w3.org/2002/07/owl#>.
11+
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
12+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
13+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
14+
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
15+
@prefix rr: <http://www.w3.org/ns/r2rml#>.
16+
@prefix schema: <http://schema.org/>.
17+
@prefix status: <http://www.w3.org/2003/06/sw-vocab-status/ns#>.
18+
@prefix wdt: <http://www.wikidata.org/prop/direct/>.
19+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
20+
21+
# level 1 (stop place)
22+
23+
[ a rr:TriplesMap ]
24+
rml:logicalSource [
25+
rml:source "data/source.json";
26+
rml:referenceFormulation ql:JSONPath;
27+
rml:iterator "$[?(@.Type == 'S')]"
28+
];
29+
rr:subjectMap [
30+
rr:template "resource/by-key/ifopt/{.DHID}";
31+
rr:class netex:StopPlace
32+
];
33+
rr:predicateObjectMap [
34+
rr:predicate netex:topographicPlace;
35+
rr:objectMap [
36+
rr:termType rr:IRI;
37+
rr:template "resource/by-key/ags/{.MunicipalityCode}"
38+
]
39+
], [
40+
rr:predicate bahnhof:ifoptStopId;
41+
rr:objectMap [
42+
rr:datatype xsd:string;
43+
rr:termType rr:Literal;
44+
rml:reference "$.DHID"
45+
]
46+
], [
47+
rr:predicate netex:name;
48+
rr:objectMap [
49+
rr:datatype xsd:string;
50+
rr:termType rr:Literal;
51+
rml:reference "$.Name"
52+
]
53+
].
54+
# todo: other attributes
55+
56+
# todo: level 2 (quay - platform), level 3 (quay - platform edge)

0 commit comments

Comments
 (0)