Last active
November 8, 2018 16:46
-
-
Save RickMoynihan/ac5bbb91da07668d3e95ee19daacebb2 to your computer and use it in GitHub Desktop.
Prettifies an RDF file by applying prefixes. Can also convert from one format to another
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
#!/usr/bin/env bash | |
":";grafter='grafter {:mvn/version "0.11.5"}' | |
":";cli='org.clojure/tools.cli {:mvn/version "0.3.7"}' | |
"exec" "clojure" "-Sdeps" "{:deps {$grafter $cli}}" "$0" "$@" | |
(require '[grafter.rdf :as rdf]) | |
(require '[grafter.rdf.io :as rio]) | |
(require '[clojure.java.io :as io]) | |
(defn write! [outfile statements] | |
(rdf/add (rio/rdf-serializer (io/file outfile) :prefixes (assoc rio/default-prefixes | |
"pmdds" "http://publishmydata.com/def/dataset#" | |
"pmdf" "http://publishmydata.com/def/ontology/folder/" | |
"csvw" "http://www.w3.org/ns/csvw#")) | |
statements)) | |
(defn prettify [infile outfile] | |
(->> infile | |
io/file | |
rdf/statements | |
(write! outfile))) | |
(prettify (first *command-line-args*) (second *command-line-args*)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Turns ugly linked data like this:
Into prettified prefixed output like this:
brew install clojure
prettify-rdf
prettify-rdf