Skip to content

Instantly share code, notes, and snippets.

@pchampin
Created September 13, 2024 09:54
Show Gist options
  • Save pchampin/7017fa5ff607e5bedf65e2f9954cfd46 to your computer and use it in GitHub Desktop.
Save pchampin/7017fa5ff607e5bedf65e2f9954cfd46 to your computer and use it in GitHub Desktop.
RDF diff
#!/bin/bash
# usage: rdfdiff <file1> <file2> [git-diff options...]
# set base URI with the BASE environment variable, if necessary
# requires a "release" build of sophia examples 'parse' and 'canonicalize'
# in a clone of https://github.com/pchampin/sophia_rs
# indicated by SOPHIA_HOME (defaults to ~/dev/sophia_rs)
#
# To produce them, run
# cargo build --all-features --release --example parse --example canonicalize
# from that directory.
set -e
set -o pipefail
base=${BASE:-http://example.org/rdfdiff/base/}
sophia=${SOPHIA_HOME:-~/dev/sophia_rs}/target/release/examples
out1=$(mktemp --suffix -rdfdiff-left.nq)
out2=$(mktemp --suffix -rdfdiff-right.nq)
SOPHIA_BASE="$base" "$sophia"/parse guess "$1" | "$sophia"/canonicalize > "$out1"
SOPHIA_BASE="$base" "$sophia"/parse guess "$2" | "$sophia"/canonicalize > "$out2"
shift 2
cd /tmp
git diff "$@" "$out1" "$out2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment