0

I am looking to transform data from a NoSQL database into RDF using pyLD. This is a snippet of the code:

doc = {
'http://example.com': 'test',
'http://purl.org/net/something#isGiven':'dose'}

context = {
'dose':{'@id':'http://purl.org/net/something#isGiven','@type':'@id'}
}

norm = jsonld.normalize(
    doc,{'algorithm': 'URDNA2015', 'format': 'application/nquads'})
print norm

This is the output generated:

_:c14n0 <http://example.com> "test" .
_:c14n0 <http://purl.org/net/something#isGiven> "dose" .

So the key of JSON becomes the property and the value the object. Now, how does one assert the subject?

I'd like my output to be:

<http://example.com/person> <http://example.com> "test" .
<http://example.com/person> <http://purl.org/net/something#isGiven> "dose" .
kurious
  • 1,024
  • 10
  • 29

1 Answers1

0

All I needed was @id as shown below:

doc = {
'http://example.com': 'test',
'http://purl.org/net/something#isGiven':'dose',
'@id':'http://example.com'}

context = {
'dose':{'@id':'http://purl.org/net/something#isGiven','@type':'@id'}
}

norm = jsonld.normalize(
    doc,{'algorithm': 'URDNA2015', 'format': 'application/nquads'})
print norm
kurious
  • 1,024
  • 10
  • 29