Skip to content

Commit

Permalink
Merge pull request #140 from dbkeator/json-ld
Browse files Browse the repository at this point in the history
WIP: jsonld ver. 1.1 exports
  • Loading branch information
dbkeator authored Jul 9, 2019
2 parents 73c91ee + 3cf6887 commit f741d2c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions nidm/experiment/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,13 @@ def serializeJSONLD(self):
#context = context2

context=self.createDefaultJSONLDcontext()


#WIP: LOOK AT https://github.com/satra/nidm-jsonld
return rdf_graph_parse.serialize(format='json-ld', context=context, indent=4).decode('ASCII')
#return rdf_graph_parse.serialize(format='json-ld', context=context, indent=4).decode('ASCII')
g=rdf_graph_parse.serialize(format='json-ld', indent=4).decode('ASCII')
import pyld as ld
return json.dumps(ld.jsonld.compact(json.loads(g), context),indent=4)

def createDefaultJSONLDcontext(self):
'''
Expand All @@ -346,7 +351,7 @@ def createDefaultJSONLDcontext(self):
#context['@context']['records']['@id'] = "@graph"


context['@version'] = "1.1"
context['@version'] = 1.1
context['records'] = {}
context['records']['@container'] = "@type"
context['records']['@id'] = "@graph"
Expand Down Expand Up @@ -403,7 +408,8 @@ def createDefaultJSONLDcontext(self):

#add prefix's from current document...this accounts for new terms
context.update ( self.prefix_to_context() )
test=self.prefix_to_context()
#test=self.prefix_to_context()

#cycle through OWL graph and add terms
# For anything that has a label

Expand All @@ -419,7 +425,7 @@ def createDefaultJSONLDcontext(self):
# else:
# context['@context'][json_key] = str(s)

print(json.dumps(context, indent=2))
#print(json.dumps(context, indent=2))
return context

def save_DotGraph(self,filename,format=None):
Expand Down
2 changes: 1 addition & 1 deletion nidm/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@
#REQUIRES = ["prov", "rdflib", "graphviz", "pydotplus", "pydot", "validators", "requests", "fuzzywuzzy", "pygithub",
# "pandas", "pybids", "duecredit", "pytest", "graphviz", "click", "ontquery"]
INSTALL_REQUIRES = ["prov", "rdflib", "graphviz", "pydotplus", "pydot", "validators", "requests", "fuzzywuzzy", "pygithub",
"pandas", "pybids", "duecredit", "pytest", "graphviz", "click", "ontquery","rdflib-jsonld"]
"pandas", "pybids", "duecredit", "pytest", "graphviz", "click", "ontquery","rdflib-jsonld","pyld"]
SCRIPTS = ["bin/nidm_query", "bin/BIDSMRI2NIDM", "bin/CSV2NIDM","bin/nidm_utils"]

0 comments on commit f741d2c

Please sign in to comment.