Skip to content

Instantly share code, notes, and snippets.

View jaw111's full-sized avatar

John Walker jaw111

  • Semaku
  • Eindhoven
View GitHub Profile
@jaw111
jaw111 / json-literals.ttl
Last active September 27, 2023 10:00
Validate rdf:JSON typed literal
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex: <http://example.com/> .
# valid JSON literals
ex:bob ex:has '{"name": robert"}'^^rdf:JSON .
ex:bob ex:has '{"name": ["robert", "bob"]}'^^rdf:JSON .
# invalid JSON literals
ex:bob ex:has '{"name": "robert"}'^^rdf:JSON .
ex:bob ex:has '{"name": ["robert", "bob",]}'^^rdf:JSON .
@jaw111
jaw111 / example.ttl
Last active June 25, 2022 13:29 — forked from pchampin/example.ttl
RDF-star "ocurrence" pattern vs. Schema.org "role" pattern vs. PROV-O "qualification" pattern
@prefix s: <http://schema.org/>.
@prefix prov: <http://www.w3.org/ns/prov#>.
# simple (unqualified) statement
:dr_strangelove a s:Movie ;
s:actor :peter_sellers.
# RDF-star with "ocurrence" nodes
@jaw111
jaw111 / OrderedCollectionRulesShape.ttl
Last active November 2, 2021 09:44
Example rule to infer skos:member for skos:OrderedCollection
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix sh: <http://www.w3.org/ns/shacl#>.
@prefix skos: <http://www.w3.org/2004/02/skos/core#>.
[] a sh:NodeShape ;
sh:targetClass skos:OrderedCollection ;
sh:rule [
a sh:TripleRule ;
sh:subject sh:this ;
sh:predicate skos:member ;
@jaw111
jaw111 / dummy.rq
Created June 24, 2020 20:53
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
@jaw111
jaw111 / data.csv
Created June 11, 2020 06:42
Tarql federation example
id name
1 SPARQL
2 SQL
3 XQuery
@jaw111
jaw111 / generate_list.ru
Created October 14, 2019 17:38
Generate list in SPARQL
prefix : <http://example.com/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix sh: <http://www.w3.org/ns/shacl#>
# insert some sample data
insert data {
#boxes
:red_box a :Box ;
:color "Red" .
:green_box a :Box ;
@jaw111
jaw111 / companies.json
Last active September 2, 2019 15:48
json2rdf
{
"content": [
{
"type": "BUYER",
"status": "RELEASED",
"duns": 214567885,
"vatno": "EU826010123",
"name": "ACME",
"name2": "Acme Corporation",
"website": "http://www.acme.com/",
{
"@id": "urn:uuid:000d7e2c-0b61-44fb-b500-95963a78d302",
"amount": "462",
"amount:2": "0",
"@context": {
"amount2": {
"@id": "http://example.com/def/mfg/amount2",
"@type": "http://www.w3.org/2001/XMLSchema#integer"
},
"amount": {
@jaw111
jaw111 / SacramentocrimeJanuary2006.csv
Last active September 17, 2018 22:33
Exercises for Tarql
We can't make this file beautiful and searchable because it's too large.
cdatetime,address,district,beat,grid,crimedescr,ucr_ncic_code,latitude,longitude
1/1/06 0:00,3108 OCCIDENTAL DR,3,3C ,1115,10851(A)VC TAKE VEH W/O OWNER,2404,38.55042047,-121.3914158
1/1/06 0:00,2082 EXPEDITION WAY,5,5A ,1512,459 PC BURGLARY RESIDENCE,2204,38.47350069,-121.4901858
1/1/06 0:00,4 PALEN CT,2,2A ,212,10851(A)VC TAKE VEH W/O OWNER,2404,38.65784584,-121.4621009
1/1/06 0:00,22 BECKFORD CT,6,6C ,1443,476 PC PASS FICTICIOUS CHECK,2501,38.50677377,-121.4269508
1/1/06 0:00,3421 AUBURN BLVD,2,2A ,508,459 PC BURGLARY-UNSPECIFIED,2299,38.6374478,-121.3846125
1/1/06 0:00,5301 BONNIEMAE WAY,6,6B ,1084,530.5 PC USE PERSONAL ID INFO,2604,38.52697863,-121.4513383
1/1/06 0:00,2217 16TH AVE,4,4A ,957,459 PC BURGLARY VEHICLE,2299,38.537173,-121.4875774
1/1/06 0:00,3547 P ST,3,3C ,853,484 PC PETTY THEFT/INSIDE,2308,38.56433456,-121.4618826
1/1/06 0:00,3421 AUBURN BLVD,2,2A ,508,459 PC BURGLARY BUSINESS,2203,38.6374478,-121.3846125
@jaw111
jaw111 / sample.csv
Created August 22, 2018 21:22
Using SPARQL 1.1 Federation with Tarql
familyName x
Allwood 10
Brandon 20
Caiazza 30