walidazizi / rdflib

Automatically exported from code.google.com/p/rdflib
Other
0 stars 0 forks source link

SPARQL parsing problem with negative values #93

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi all, and thanks for the great library.

>>> rdflib.__version__
'2.4.2'

I am having problems with the following code, obtained from test_not_equals.py

from rdflib.Namespace import Namespace
from rdflib import plugin,RDF,RDFS,URIRef, StringInputSource, Literal
from rdflib.Graph import Graph,ReadOnlyGraphAggregate,ConjunctiveGraph
import rdflib
import sys
from pprint import pprint

def testSPARQLNotEquals():
    NS = u"http://example.org/"
    graph = ConjunctiveGraph()
    graph.parse(StringInputSource("""
       @prefix    : <http://example.org/> .
       @prefix rdf: <%s> .
       :foo rdf:value 1.
       :bar rdf:value -2."""%RDF.RDFNS), format="n3")
    rt = graph.query("""SELECT ?node 
                        WHERE {
                                ?node rdf:value ?val.
                                FILTER (?val < -1)
                               }""",
                           initNs={'rdf':RDF.RDFNS },                     

                           DEBUG=False)
    for row in rt:        
        item = row[0]
        print item
        #assert item == URIRef("http://example.org/bar")

if __name__ == '__main__':
    testSPARQLNotEquals()

Get this error:

Traceback (most recent call last):
  File "test_not_equals.py", line 29, in ?
    testSPARQLNotEquals()
  File "test_not_equals.py", line 22, in testSPARQLNotEquals
    DEBUG=False)
  File
"/Users/sbo/Work/Programs/Experimental/rdflib/rdflib-2.4.2/test/Graph.py",
line 738, in query

  File "build/bdist.macosx-10.6-i386/egg/rdflib/sparql/bison/Processor.py",
line 50, in query
  File "build/bdist.macosx-10.6-i386/egg/rdflib/sparql/Algebra.py", line
312, in TopEvaluate
  File "build/bdist.macosx-10.6-i386/egg/rdflib/sparql/Algebra.py", line
165, in ReduceToAlgebra
  File
"build/bdist.macosx-10.6-i386/egg/rdflib/sparql/bison/SPARQLEvaluate.py",
line 318, in createSPARQLPConstraint
  File "<string>", line 0, in ?
TypeError: bad operand type for unary -

Can you propose workarounds, if it's a bug ?

Original issue reported on code.google.com by stefano....@gmail.com on 24 Nov 2009 at 11:47

GoogleCodeExporter commented 8 years ago

Original comment by eik...@gmail.com on 1 Feb 2010 at 7:27

GoogleCodeExporter commented 8 years ago

Original comment by eik...@gmail.com on 1 Feb 2010 at 8:02

GoogleCodeExporter commented 8 years ago
These issues involve bits that have been moved out of rdflib proper for now. We 
will re-open them 
or move them to rdfextas as appropriate.

Original comment by eik...@gmail.com on 11 Feb 2010 at 6:06