You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
453 B
Python
22 lines
453 B
Python
9 months ago
|
import rdflib
|
||
|
import json
|
||
|
import argparse
|
||
|
|
||
|
|
||
|
ap = argparse.ArgumentParser("")
|
||
|
ap.add_argument("input", nargs="+")
|
||
|
args = ap.parse_args()
|
||
|
|
||
|
context = None
|
||
|
u = rdflib.Graph()
|
||
|
for i in args.input:
|
||
|
if context is None:
|
||
|
with open(i) as fin:
|
||
|
data = json.load(fin)
|
||
|
if '@context' in data:
|
||
|
context = data['@context']
|
||
|
g = rdflib.Graph()
|
||
|
g.parse(i)
|
||
|
u += g
|
||
|
|
||
|
print (u.serialize(format="json-ld", context=context))
|