You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SPARQL property paths in rdflib.paths are great for slicing, etc.
However, there is no straightforward way to get back actual, usable SPARQL syntax for more complex query patterns, even though the user would have to understand said syntax to make sense of what comes out of __repr__, or create it with the handy typographic shortcuts!
What I would like is:
fromrdflib.namespacesimportFOAF, RDFSpath=~FOAF.knows/RDFS.label# some magic"~<http://xmlns.com/foaf/0.1/knows>/<http://www.w3.org/2000/01/rdf-schema#label>"
Wondering aloud - all rdflib nodes have a n3 method - the n3 and sparql syntax is (almost always) identiical - clearly path objects have no direct n3 representation, but we could bastardize this method for this purpose.
It's also on a list somewhere to allow reserializing parsed SPARQL query objects as SPARQL strings - this method could be useful there.
N3 does have path expressions using the ! and ^ operators. (Although there are no path expressions of arbitrary length.) As N3's and SPARQL's syntax for path expressions differ, you should not use the n3 method to produce SPARQL.
N3 does have path expressions using the ! and ^ operators. (Although there are no path expressions of arbitrary length.) As N3's and SPARQL's syntax for path expressions differ, you should not use the n3 method to produce SPARQL.
#553 Added a n3 method to Paths. Since that method is used by the SPARQLStore by default for generation of queries, is the above comment effectively no longer valid? If so, can this issue be marked as resolved?
The SPARQL property paths in
rdflib.paths
are great for slicing, etc.However, there is no straightforward way to get back actual, usable SPARQL syntax for more complex query patterns, even though the user would have to understand said syntax to make sense of what comes out of
__repr__
, or create it with the handy typographic shortcuts!What I would like is:
The
__repr__
methods almost do this:Perhaps implementing
__str__
, in addition to__repr__
, and having each callstr
andrepr
repectively, would work:In the meantime, I am using this: just making this available could be helpful.
The text was updated successfully, but these errors were encountered: