Open cmaumet opened 8 years ago
PR submitted: https://github.com/RDFLib/rdflib/pull/660
@cmaumet - i tested with this.
from prov.model import ProvDocument, Namespace, QualifiedName
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/incf-nidash/nidm/master/nidm/nidm-results/terms/prefixes.csv')
df['Namespace'] = df[['Preferred prefix', 'URI']].apply(lambda x: Namespace(x['Preferred prefix'], x['URI']), axis=1)
prefixes = dict(df[['URI', 'Namespace']].values)
g = ProvDocument()
group_name_uri = "http://purl.org/nidash/nidm#NIDM_0000170"
for prefix in prefixes:
if prefix == group_name_uri:
g.add_namespace(prefixes[prefix])
group_name_uri = "http://purl.org/nidash/nidm#NIDM_0000170"
ex = Namespace('ex', 'http://example/')
g.entity(ex['group1'], {group_name_uri: "Group 1"})
print(g.serialize(format='provn'))
print("---")
print(g.serialize(format='rdf', rdf_format="turtle"))
Thank you @satra!
this has been superceded by this PR, which takes performance into account: https://github.com/RDFLib/rdflib/pull/649
Hi @satra, @trungdong,
I am trying to use
Namespace
to specify prefixes for our alphanumeric identifiers and though this works fine with provn, it can't get it to work with the turtle serialisation. Any help would be greatly appreciated!Here is a minimal example:
and the output:
I would like
ns1:NIDM_0000170
to be replaced bynidm_groupName:
in the turtle document.