Skip to content

Instantly share code, notes, and snippets.

@jindrichmynarz
Last active October 6, 2016 20:53
Show Gist options
  • Save jindrichmynarz/8fda968debb1d3a3873bcf3a41ba37c5 to your computer and use it in GitHub Desktop.
Save jindrichmynarz/8fda968debb1d3a3873bcf3a41ba37c5 to your computer and use it in GitHub Desktop.
Fuse subset descriptions
PREFIX : <http://example.com/>
DELETE {
?r1 ?outP ?outO .
?inS ?inP ?r1 .
}
INSERT {
?inS ?inP ?r2 .
}
WHERE {
{
SELECT DISTINCT ?r1 ?r2
WHERE {
# Select resources to fuse.
?r1 a :C .
?r2 a :C .
FILTER (!sameTerm(?r1, ?r2))
# There's no property-value pair of ?r1 that ?r2 doesn't have.
FILTER NOT EXISTS {
?r1 ?p ?o .
FILTER NOT EXISTS {
?r2 ?p ?o .
}
}
}
}
?r1 ?outP ?outO .
OPTIONAL {
?inS ?inP ?r1 .
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment