コード例 #1
0
# Get links to metadata documents referenced from a SO:dataset
import sotools
from pprint import pprint

json_source = "examples/data/ds_m_subjectof.json"
g = sotools.loadSOGraph(filename=json_source,
                        publicID="https://my.server.net/data/")
links = sotools.getDatasetMetadataLinks(g)
pprint(links, indent=2)
コード例 #2
0
# Load a graph and evaluate if it contains a SO:Dataset
import sotools

g = sotools.loadSOGraph(filename="examples/data/ds_bad_namespace.json",
                        publicID="https://my.data.net/data/")
sotools.hasDataset(g)
コード例 #3
0
# Load graph and show SO:Dataset.identifier entries
import sotools
import json
from pprint import pprint

json_source = "examples/data/id_structured_01.json"
g = sotools.loadSOGraph(filename=json_source)
identifiers = sotools.getDatasetIdentifiers(g)
print("The json-ld source graph:")
print(json.dumps(json.load(open(json_source, 'r')), indent=2))
print("\nThe identifier(s) used in the dataset:")
pprint(identifiers, indent=2)
コード例 #4
0
# Load a Dataset from json-ld, normalize schema.org namespace, and dump as ttl.
import sotools
import json

json_source = "examples/data/ds_bad_namespace.json"
g = sotools.loadSOGraph(filename=json_source,
                        publicID="https://my.data.net/data/",
                        normalize=True,
                        deslop=True)

print("Loaded JSON:")
print(json.dumps(json.load(open(json_source, 'r')), indent=2))
print("\nNormalized schema.org namespace and serialized to ttl:\n")
print(g.serialize(format="ttl").decode())