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 / 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 / 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 / fileSplit
Created January 2, 2014 08:59
Simple VBA macro to split a text file (*.txt) into chunks where maximum number of lines for each chunk is entered by user. The output files get the same name as the source text file, but with _1, _2,... appended to the file name (example.txt => example_1.txt, example_2.txt etc.).
Sub split()
Dim fNameAndPath As Variant
Dim TextLine, fName
Dim fileCount, myCount, numberOfLines As Integer
Dim outputFile
myCount = 0
fileCount = 1
fNameAndPath = Application.GetOpenFilename(FileFilter:="Text files (*.txt), *.txt", Title:="Select File To Be Opened")
@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 / data.csv
Created June 11, 2020 06:42
Tarql federation example
id name
1 SPARQL
2 SQL
3 XQuery
@jaw111
jaw111 / gs1.jsonld
Last active February 12, 2021 00:55
GS1 GTIN+ OTW JSON-LD example
{
"@context": {
"gs1": "http://gs1.org/voc/",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"gtin13": {
"@id": "gs1:gtin13",
"@type": "xsd:string"
},
"ingredientpercentage": {
"@id": "gs1:ingredientpercentage",
@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 / 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": {