-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expected behaviour of Dataset.triples
? I think it always returns an empty list
#2959
Comments
Hi @WhiteGobo In your example file, there are two named graphs, and no default graph. a) If Two things to point out.
|
Here is some code to illustrate the behaviour of from rdflib import *
GraphString = '''
PREFIX eg: <http://example.com/person/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
eg:graph-1 {
eg:drewp a foaf:Person .
eg:drewp eg:says "Hello World" .
}
eg:graph-2 {
eg:nick a foaf:Person .
eg:nick eg:says "Hi World" .
}
eg:ash a foaf:Person .
eg:ash eg:says "Default" .
'''
ds = Dataset()
ds.parse(data=GraphString, format="trig")
ds.default_union = False
print(list(ds.triples((None, None, None))))
# returns only the triples from the "default" graph:
# > eg:ash a foaf:Person
# > eg:ash eg:says "Default"
print(list(ds.triples((None, None, None, URIRef("http://example.com/person/graph-1")))))
# Returns only from "graph-1" named graph:
# > eg:drewp a foaf:Person
# > eg:drewp eg:says "Hello World"
ds.default_union = True
print(list(ds.triples((None, None, None))))
# with default_union=True it returns everything
# > eg:drewp a foaf:Person
# > eg:drewp eg:says "Hello World"
# > eg:nick a foaf:Person
# > eg:nick eg:says "Hi World"
# > eg:ash a foaf:Person
# > eg:ash eg:says "Default" |
ok thx for the explanation. This solves the problem. |
This is a question related to issue #2958 . During sparql evaluation
graph.triples
is used to find triples in context.So with given data, no triples are returned. Dataset doesnt has any identifier, so it should return all available triples right?
The text was updated successfully, but these errors were encountered: