Hi D.C,

Can I just reflect back the question at you to see if it is understood? Are you 
asking for something like this:


import rdflib

# 1
base_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
  - which is the base URI of the W3C’s Profiles Vocabulary, see 
https://www.w3.org/TR/dx-prof/ <https://www.w3.org/TR/dx-prof/>
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





> On 29 Dec 2019, at 12:27 am, [email protected] wrote:
> 
> Hello,
> 
> I'd like to search a large data set for all terms of a base URI. Can this be 
> done with rdflib?
> Something like 
> for s,p,o in g.triples( (None, DEFAULT['None'], None) ):
>     print("{} {} {}".format(s, p, o))
> ?
> 
> And then to split the term, Instead of 
> <http://some.default.base/#InterestingTerm> 
> 
> just 
> 
> InterestingTerm
> 
> -- 
> http://github.com/RDFLib
> --- 
> You received this message because you are subscribed to the Google Groups 
> "rdflib-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rdflib-dev/f7951ae6-d82d-4eab-8b7e-cf078cda6bd2%40googlegroups.com.

-- 
http://github.com/RDFLib
--- 
You received this message because you are subscribed to the Google Groups 
"rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rdflib-dev/37D847C8-C9B8-49EF-81F1-C100D3B16653%40surroundaustralia.com.

Reply via email to