If you are just looking to strip the leading namespace from any URI string, 
you could do the following:

import re
from rdflib import URIRef

def simplify(term):
  return re.sub(r'^.*[#/]', '', str(term)) if isinstance(term, URIRef) else 
str(term)

for s,p,o in g.triples( (None, DEFAULT['None'], None) ):
    print("{} {} {}".format(simplify(s), simplify(p), simplify(o)))

On Saturday, December 28, 2019 at 9:27:22 AM UTC-5, [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/8afa05e5-93bb-4886-962a-62a2677fb82c%40googlegroups.com.

Reply via email to