Skip to content

Commit

Permalink
add ld setup
Browse files Browse the repository at this point in the history
  • Loading branch information
juliuste committed Dec 28, 2024
1 parent 2aee946 commit 7c1fbbb
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,23 @@ jobs:
echo 'file unchanged, skipping.'
fi;
- name: "Generate linked data: DE_ZHV"
# todo: do not run if processing the dataset failed
if: ${{ success() }} # this should allow the other steps to run, but should still mark the workflow as failing
env:
DO_SPACES_BUCKET_NAME: ${{ secrets.DO_SPACES_BUCKET_NAME }}
run: |
set -e;
./src/linked-data/zhv-de/index.sh
currentobj=$(aws s3api head-object --bucket $DO_SPACES_BUCKET_NAME --key de/zhv.ttl.gz || echo 'not-yet-existing');
newhash=$(cat ./src/linked-data/zhv-de/data/output.ttl.gz | md5sum);
if [ $(echo $currentobj | grep $newhash | wc -l) -ne 1 ]
then
aws s3 cp --acl public-read ./src/linked-data/zhv-de/data/output.ttl.gz s3://"$DO_SPACES_BUCKET_NAME"/de/zhv.ttl.gz
else
echo 'file unchanged, skipping.'
fi;
- name: "Fetch and upload feed: DE_NRW_GTFS"
if: ${{ success() || failure() }} # this should allow the other steps to run, but should still mark the workflow as failing
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ shrinkwrap.yaml
pnpm-lock.yaml
dist

data
*.zip
2 changes: 2 additions & 0 deletions src/linked-data/.bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
27 changes: 27 additions & 0 deletions src/linked-data/zhv-de/index.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -e
DIR=$(dirname "$0")
BASE_IRI="https://lod.codefor.de/"
BIN_DIR="$DIR/../.bin"
DATA_DIR="$DIR/data"

echo 'Fetching rmlmapper'
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

rm -rf "$DATA_DIR"
mkdir -p "$DATA_DIR"

echo 'Preparing data…'
cp "$DIR/../../../de-zhv.zip" "$DATA_DIR/source.zip"
unzip "$DATA_DIR/source.zip" -d "$DATA_DIR/unzipped"
find "$DATA_DIR/unzipped/" -name "*.csv" -exec mv '{}' "$DATA_DIR/source.csv" \;

pnpx csvtojson --delimiter=";" "$DATA_DIR/source.csv" > "$DATA_DIR/source.json"

echo 'Applying mapping…'
java -jar "$BIN_DIR/rmlmapper.jar" -m "$DIR/mapping.ttl" -s turtle --strict --base-iri "$BASE_IRI" > "$DATA_DIR/output.ttl"

echo 'Compressing output…'
cat "$DATA_DIR/source.csv" | gzip > "$DATA_DIR/output.ttl.gz"

# echo 'Done.'
56 changes: 56 additions & 0 deletions src/linked-data/zhv-de/mapping.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@prefix bahnhof: <https://lod.bahnhof.de/vocabulary/db/>.
@prefix codeforde: <https://lod.codefor.de/vocabulary/codeforde/>.
@prefix dct: <http://purl.org/dc/terms/>.
@prefix dbo: <https://dbpedia.org/ontology/>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix geo: <http://www.opengis.net/ont/geosparql#>.
@prefix gn: <http://www.geonames.org/ontology#>.
@prefix juso: <http://rdfs.co/juso/>.
@prefix netex: <https://lod.bahnhof.de/vocabulary/netex/>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix schema: <http://schema.org/>.
@prefix status: <http://www.w3.org/2003/06/sw-vocab-status/ns#>.
@prefix wdt: <http://www.wikidata.org/prop/direct/>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.

# level 1 (stop place)

[ a rr:TriplesMap ]
rml:logicalSource [
rml:source "data/source.json";
rml:referenceFormulation ql:JSONPath;
rml:iterator "$[?(@.Type == 'S')]"
];
rr:subjectMap [
rr:template "resource/by-key/ifopt/{.DHID}";
rr:class netex:StopPlace
];
rr:predicateObjectMap [
rr:predicate netex:topographicPlace;
rr:objectMap [
rr:termType rr:IRI;
rr:template "resource/by-key/ags/{.MunicipalityCode}"
]
], [
rr:predicate bahnhof:ifoptStopId;
rr:objectMap [
rr:datatype xsd:string;
rr:termType rr:Literal;
rml:reference "$.DHID"
]
], [
rr:predicate netex:name;
rr:objectMap [
rr:datatype xsd:string;
rr:termType rr:Literal;
rml:reference "$.Name"
]
].
# todo: other attributes

# todo: level 2 (quay - platform), level 3 (quay - platform edge)

0 comments on commit 7c1fbbb

Please sign in to comment.