Created
April 7, 2017 09:44
-
-
Save jindrichmynarz/2d5bd070ab765141151c9a82eda9f556 to your computer and use it in GitHub Desktop.
Generate 0 to 10 random RDF triples
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
PREFIX : <http://localhost/> | |
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | |
CONSTRUCT { | |
?s ?p ?o . | |
} | |
WHERE { | |
# Generate 0 to 10 triples | |
VALUES ?n { 0 1 2 3 4 5 6 7 8 9 10 } | |
BIND (if(rand() < 1/3.0, bnode(), | |
if(rand() < 1/2.0, uuid(), iri(concat(str(:), struuid())))) AS ?s) | |
BIND (if(rand() < 1/2.0, uuid(), iri(concat(str(:), struuid()))) AS ?p) | |
BIND (if(rand() < 1/3.0, xsd:decimal, | |
if(rand() < 1/2.0, xsd:float, xsd:double)) AS ?datatype) | |
BIND (if(rand() < 1/7.0, struuid(), | |
if(rand() < 1/6.0, sha512(str(now())), | |
if(rand() < 1/5.0, strdt(rand() * 100, ?datatype), | |
if(rand() < 1/4.0, strlang(struuid(), "zxx"), | |
if(rand() < 1/3.0, xsd:date(now()), | |
if(rand() < 1/2.0, now(), xsd:boolean(rand() > 0.5))))))) AS ?literal) | |
BIND (if(rand() < 1/4.0, ?literal, | |
if(rand() < 1/3.0, bnode(), | |
if(rand() < 1/2.0, uuid(), iri(concat(str(:), struuid()))))) AS ?o) | |
FILTER (floor(rand() * 11) < ?n) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment