Skip to content

Trig format cannot be processed by RDFLib #2958

@floresbakker

Description

@floresbakker

Data in Trig format cannot be processed by RDFLib.

Let us assume the following data including graphs (example copied from RDFlib documentation)

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" .
}
'''

Next, let's parse this data into a Graph object:

someGraph = Graph()
someGraph.parse(data=GraphString , format="trig")

Let us query the graph:

someQuery = someGraph.query('''
       
select ?s

where  {
         ?s ?p ?o     
       }   
''')   

If we then go through the result set, there is unexpectedly nothing:

for row in someQuery:
        print (str(row.s))

This does not lead to any result, whereas I would expect the following bindings for the variable ?s .

http://example.com/person/drewp
http://example.com/person/nick
http://example.com/person/drewp
http://example.com/person/nick

If I prepare the data differently by removing the explicit graphs, I do get the expected results:

GraphString = '''

PREFIX eg: <http://example.com/person/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

   eg:drewp a foaf:Person .
   eg:drewp eg:says "Hello World" .

   eg:nick a foaf:Person .
   eg:nick eg:says "Hi World" .
'''

Result of the query:

http://example.com/person/drewp
http://example.com/person/nick
http://example.com/person/drewp
http://example.com/person/nick

Perhaps I am mistaken in this and I should work in a different way with rdflib graph objects in Python that contain trig data, but it does seem incorrect behavior from purely a triples & sparql point of view.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions