Can I just reflect back the question at you to see if it is understood? Are you asking for something like this:
import rdflib
# 1base_uri = 'http://www.w3.org/ns/dx/prof/‘
# 2
g = rdflib.Graph().parse('prof.ttl', format='turtle’)
# 3
for s, p, o in g.triples((None, None, None)):
# 4
if str(s).startswith(base_uri):
print('s {} - {}'.format(str(s).split('/')[-1], s))
elif str(p).startswith(base_uri):
print('p {} - {}'.format(str(p).split('/')[-1], p))
elif str(o).startswith(base_uri):
print('o {} - {}'.format(str(o).split('/')[-1], o))
So here, following numbered comments in the code:
1. Identifying a base URI
2. Reading an RDF source
- the file prof.ttl which contains the Profiles Vocabulary
3. Looping through all triples in theta source
- which is the Profiles Vocabulary in a file, but could be a huge dataset
4. Testing to see if each part (here a Subject s) starts with a base_uri
- splits and grits it if it does
Are there other things you want to be doing or is this it?
Cheers,
Nick