Hello!

I did some digging and discovered that the test will work (using
latest trunk, 1236 right now) if you change DAWG_DATASET_COMPLIANCE in
"rdflib/sparql/Algebra.py" to False. Not sure wether or not this
signifies a much bigger problem, my example code below does it by
"monkey patch" (and I will not change this in the file for now, I feel
it may be a more deep problem).

This is the "test" code I used. (Please notice my use of FILTER - I'm
not sure wether that is needed in SPARQL or if the spec says that
SPARQL does no such "no uniqueness assumption" for bindings by
default.)

----------------- 8< -------------------

from rdflib import ConjunctiveGraph as CG, Namespace
from rdflib.sparql import Algebra
Algebra.DAWG_DATASET_COMPLIANCE = False

data = """
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix : <tag:example.org,2007;stuff/> .

:a foaf:knows :b .
:a foaf:knows :c .
:a foaf:knows :d .

:b foaf:knows :a .
:b foaf:knows :c .

:c foaf:knows :a .

"""

q = """
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

select distinct ?person
where {
     ?person foaf:knows ?a .
     ?person foaf:knows ?b .
    filter (?a != ?b) .
}
"""

g = CG()
from StringIO import StringIO
g.parse(StringIO(data), format='n3')
print g.query(q).serialize('json')

----------------- >8 -------------------

(Also, the JSON serialization chops "p" off of "person". It was
introduced by a change in Variable.py at revision 1166, but it looks
reasonable to fix "sparql/QueryResult.py" instead (which compensates
for the old way with a bunch of reasonably obsolete "[1:]" chopping).
I will probably do that in a while.)


Best regards,
Niklas


On 8/6/07, whit <[EMAIL PROTECTED]> wrote:
> ok... makes me feel a little less nuts.  will create a test case.
>
> -w
>
> On 8/6/07, Drew Perttula <[EMAIL PROTECTED] > wrote:
> > whit wrote:
> > > I'm trying to do a match like so:
> > >
> > > select distinct ?person
> > > where {
> > >      ?person foaf:knows ?a .
> > >      ?person foaf:knows ?b .
> > > }
> > >
> > > in plain terms, I want all people who know both ?a and ?b .  My query
> > > work if I include just a single pattern (ala ?person foaf:knows ?a or
> > > ?person foaf:knows ?b) but fails if both pattern are present despite
> > > triples representing persons knowing ?a and ?b.
> >
> > Looks right to me (assuming you bound ?a and ?b). Does it behave
> > differently without 'distinct'? I recommend writing this into a test
> > case if you can. Then we'll all have exactly the same code to run, and
> > we can put it in the suite so it gets run on every future version of
> rdflib.
> >
>
>
>
> --
>
>  | david "whit" morriss
>  |
>  | contact :: http://public.xdi.org/=whit
>
>  "If you don't know where you are,
>   you don't know anything at all"
>
>   Dr. Edgar Spencer, Ph.D., 1995
>
>
>  "I like to write code like
>  other ppl like to tune their
>  cars or 10kW hifi equipment..."
>
>  Christian Heimes, 2004
>
> _______________________________________________
> Dev mailing list
> Dev@rdflib.net
> http://rdflib.net/mailman/listinfo/dev
>
>
_______________________________________________
Dev mailing list
Dev@rdflib.net
http://rdflib.net/mailman/listinfo/dev

Reply via email to