Skip to content

Instantly share code, notes, and snippets.

@jaw111
Created June 24, 2020 20:53
Show Gist options
  • Save jaw111/e3aea75efc848f0ff4a71eb74d85a7fb to your computer and use it in GitHub Desktop.
Save jaw111/e3aea75efc848f0ff4a71eb74d85a7fb to your computer and use it in GitHub Desktop.
Generate stupid amount of RDF statements from minimal amount of CSV input
base <http://example.com/id/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
construct {
?uuid ?member ?num .
}
where {
# this mapping generates 1M unique statements for each record in an arbitrary input csv file
# mint a uuid iri for each record in the input csv
bind(uuid() as ?uuid)
{
# generate bindings for integer numbers from 0 to 999999 and corresponding container membership properties rdf:_0, rdf:_1, rdf:_2 ...
select ?num ?member
where {
values ?i { 0 1 2 3 4 5 6 7 8 9 }
values ?j { 0 1 2 3 4 5 6 7 8 9 }
values ?k { 0 1 2 3 4 5 6 7 8 9 }
values ?l { 0 1 2 3 4 5 6 7 8 9 }
values ?m { 0 1 2 3 4 5 6 7 8 9 }
values ?n { 0 1 2 3 4 5 6 7 8 9 }
bind((?i + (?j * 10) + (?k * 100) + (?l * 1000) + (?m * 10000) + (?n * 100000)) as ?num)
bind(iri(concat("http://www.w3.org/1999/02/22-rdf-syntax-ns#_", str(?num))) as ?member)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment