Skip to content

Instantly share code, notes, and snippets.

@cmaumet
Last active August 10, 2018 13:57
Show Gist options
  • Save cmaumet/bcf93daec19f974aa27be38bfc0a876e to your computer and use it in GitHub Desktop.
Save cmaumet/bcf93daec19f974aa27be38bfc0a876e to your computer and use it in GitHub Desktop.
Small JSON-LD and the turtle we would like to have
{
"@context": {
"DesignMatrix": "http://purl.org/nidash/nidm#DesignMatrix",
"value": "http://path_to_prov#value",
"regressorNames": "http://purl.org/nidash/nidm#regressorNames",
"hasDriftModel": "http://purl.org/nidash/nidm#hasDriftModel",
"SPMsDriftCutoffPeriod": "http://purl.org/nidash/spm#spm_SPMsDriftCutoffPeriod"
},
"DesignMatrix":
{
"value": 1,
"regressorNames": "Sn(1) active*bf(1)",
"hasDriftModel": "spm_DiscreteCosineTransformbasisDriftModel",
"SPMsDriftCutoffPeriod": 128
}
}
@prefix ns1: <http://purl.org/nidash/spm#> .
@prefix ns2: <http://purl.org/nidash/nidm#> .
@prefix ns3: <http://path_to_prov#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
_:b0 a ns2:DesignMatrix ;
ns3:value 1 ;
ns2:hasDriftModel "spm_DiscreteCosineTransformbasisDriftModel" ;
ns2:regressorNames "Sn(1) active*bf(1)" ;
ns1:spm_SPMsDriftCutoffPeriod 128 .
{
"@context": {
"schema": "http://schema.org/",
"name": "schema:name",
"body": "schema:articleBody",
"words": "schema:wordCount",
"post": {
"@id": "schema:blogPost",
"@container": "@index"
}
},
"@id": "http://example.com/",
"@type": "schema:Blog",
"name": "World Financial News",
"post": {
"en": {
"@id": "http://example.com/posts/1/en",
"body": "World commodities were up today with heavy trading of crude oil...",
"words": 1539
},
"de": {
"@id": "http://example.com/posts/1/de",
"body": "Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl...",
"words": 1204
}
}
}
prefix id1: http://example.com/
prefix id2: http://example.com/posts/1/en
prefix id3: http://example.com/posts/1/de
id1: rdf:type schema:Blog;
schema:name "World Financial News";
schema:blogPost id2:;
schema:blogPost id3:.
id2: schema:articleBody "World commodities were up today with heavy trading of crude oil...";
schema:wordCount 1539 .
id3: schema:articleBody "Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl...";
schema:wordCount 1204 .
[
{
"@id": "_:f3b7e650dbc984360a84540b1b042c203b1",
"@type": [
"http://purl.org/nidash/nidm#DesignMatrix"
],
"http://path_to_prov#value": [
{
"@value": 1
}
],
"http://purl.org/nidash/nidm#hasDriftModel": [
{
"@value": "spm_DiscreteCosineTransformbasisDriftModel"
}
],
"http://purl.org/nidash/nidm#regressorNames": [
{
"@value": "Sn(1) active*bf(1)"
}
],
"http://purl.org/nidash/spm#spm_SPMsDriftCutoffPeriod": [
{
"@value": 128
}
]
}
]
@prefix ns1: <http://purl.org/nidash/spm#> .
@prefix ns2: <http://path_to_prov#> .
@prefix ns3: <http://purl.org/nidash/nidm#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
[] ns3:DesignMatrix [ ns2:value 1 ;
ns3:hasDriftModel "spm_DiscreteCosineTransformbasisDriftModel" ;
ns3:regressorNames "Sn(1) active*bf(1)" ;
ns1:spm_SPMsDriftCutoffPeriod 128 ] .
import rdflib
g=rdflib.Graph()
g.parse("my_file.json", format='json-ld')
g.serialize("my_file.ttl", format='turtle')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment