Re: a few patch challenges

On 08/11/2014 04:12 PM, Alexandre Bertails wrote:
> On Mon, Aug 11, 2014 at 11:39 AM, Sandro Hawke <sandro@w3.org> wrote:
>> Arguably we should have made a patch test suite years ago.
>>
>> Off the top of my head, here are a few patch challenges.    It's not
>> necessarily a requirement that they all be done, but I think it would help
>> show the differences to see how they are done in ldpatch, etc.
> You can find the result at [1].

Impressive, thanks.

Do you have code to generate patches?    I gather you made these ones by 
hand.

Some syntactic concerns which I've mentioned before.  My apologies if 
there's been a response I missed.   Also, the attendeeOf bug is still 
there in the spec.

1.  Why these seemingly gratuitous differences from SPARQL path expression:

    - instead of ^ for inverse path operator

    paths start with / instead of having it be an infix operator

?

2.  Why > as the slice operator?   It looks like the vast majority [1] 
of languages use colon, and the the rest use "..".   I think either of 
those would be familiar to experienced programmers, unlike >.    I 
suppose I'd pick .. because colon seems too much like a pname, but I'm 
fine with colon, too.

[1] http://en.wikipedia.org/wiki/Array_slicing

3.  Why square brackets for filter?   I'd think parens for grouping, 
then = for filter would do it.     Doing that and making / infix (as in 
sparql) instead of prefix, we'd get:

    Bind ?event <#> schema:attendeeOf/(schema:url =
    <http://conferences.ted.com/TED2009/>)

Alternatively, if you keep square brackets, there's no need for the 
equal sign, either for parsing, or for looking familiar.

--

I think my biggest advice, and this is what keeps making me raise my 
voice during meetings -- for which I'm sorry -- is to understand that 
you've created a new language here, and you have to teach it to your 
audience.  You can't just say "it's just patch".  Your audience is going 
to take a while to learn it, as they do any new language.

I'd suggest giving them a series of increasing examples, such as the 
test cases I posed to you, so they can see that blank nodes get selected 
from the nearest node via forward or backward arcs, then filtered if 
necessary.   Which makes me think....

== TEST 9
== FROM
<alice> <knows >
      [ <first> "Bob", <last> "Smith" ],
      [ <first> "Bob", <last> "Jones" ],
      [ <first> "Charlie", <last> "Smith" ],
      [ <first> "Charlie", <last> "Jones" ].
== TO
<alice> <knows >
      [ <first> "Bob", <last> "Smith" ],
      [ <first> "Bob", <last> "Jones" ],
      [ <first> "Charlie", <last> "Smith" ],
      [ <first> "Chuck", <last> "Jones" ].
== END

Every language features needs a test in the test suite, and really 
should be motivated by a use case.   If you allow multiple filters in 
one path, provide an example where that's necessary.  (I think that's 
what Test 9 is.)

And just to push a tiny bit more, to make sure we can step after the filter:

== TEST 10
Somewhat artificial use of <text> but surely there are situations like this
== FROM
<alice> <knows >
      [ <first> [ <text> "Bob"], <last> [ <text> "Smith"] ],
      [ <first> [ <text> "Bob"], <last> [ <text> "Jones"] ],
      [ <first> [ <text> "Charlie"], <last> [ <text> "Smith"] ],
      [ <first> [ <text> "Charlie"], <last> [ <text> "Jones"] ].
== TO
<alice> <knows >
      [ <first> [ <text> "Bob"], <last> [ <text> "Smith"] ],
      [ <first> [ <text> "Bob"], <last> [ <text> "Jones"] ],
      [ <first> [ <text> "Charlie"], <last> [ <text> "Smith"] ],
      [ <first> [ <text> "Chuck"], <last> [ <text> "Jones"] ].
== END

Is the value of Bind unique, or can it be a set?   That is, is ! 
implicit in bind?  If not, can every path expression be re-written as a 
sequence of single-step Bind operations?

To try my understanding, how's this:

Bind ?CharlieJones "Charlie" /-<text>/-<first>/[/<last>/<text> = "Jones"]!

How about three properties being needed:

== TEST 11
== FROM
<alice> <knows >
      [ <first> "Bob", <middle> "A", <last> "Smith" ],
      [ <first> "Bob", <middle> "B", <last> "Smith" ],
      [ <first> "Bob", <middle> "A", <last> "Jones" ],
      [ <first> "Bob", <middle> "B", <last> "Jones" ],
      [ <first> "Charlie", <middle> "A", <last> "Smith" ],
      [ <first> "Charlie", <middle> "B", <last> "Smith" ],
== TO
== END

Then I guess we'd use something like:

Bind ?BobASmith <alice> /<knows>[/<first> = "Bob"][/<middle> = 
"A"][/<last> = "Jones"]!

Right?

        - s

> All tests that are not about pathological graphs pass with the
> implementation matching the current spec.
> It works both with Jena, and Sesame, and the pure Scala implementation.
>
> Please read the comments inside the code for more information.
>
> Alexandre
>
> [1] https://github.com/betehess/banana-rdf/blob/d49e417c6c5560a6a852e587318da4493d25f5b1/ldpatch/src/test/scala/SandrosChallenge.scala
>
>
>>        -- Sandro
>>
>>
>> ==TEST 1
>> ==FROM
>> <alice> <knows> <bob>, <charlie>.
>> ==TO
>> <alice> <knows> <bob>, <dave>.
>> ==END
>>
>>
>> ==TEST 2
>> ==FROM
>> <alice> <knows> ( <bob> <charlie> )
>> ==TO
>> <alice> <knows> ( <bob> <dave> )
>> ==END
>>
>>
>>
>> ==TEST 3
>> ==FROM
>> <alice> <knows> [ <knows> <bob> ], [<knows> <charlie>].
>> ==TO
>> <alice> <knows> [ <knows> <bob> ], [<knows> <dave>].
>> ==END
>>
>> ==TEST 4
>> ==FROM
>> <alice> <knows>
>>     [ <name> "Bob" ],
>>     [ <name> "Charlie"].
>> ==TO
>> <alice> <knows>
>>     [ <name> "Bob" ],
>>     [ <name> "Dave"].
>> ==END
>>
>> ==TEST 5 (two changes: the secound count, and the second street addr)
>> ==FROM
>> [ a <Order>;
>>    <items> (
>>       [ <code> "4343"; <count> 1 ]
>>       [ <code> "4344"; <count> 3 ]
>>       [ <code> "4347"; <count> 3 ]
>>    );
>>    <shipTo> [
>>       a <Address>;
>>       <street> [ <num> 32; <name> "Vassar St" ];
>>       <city> "Cambridge";
>>       <state> "MA";
>>       <zip> 02139
>>    ];
>>    <billTo> [
>>       a <Address>;
>>       <street> [ <num> 32; <name> "Vassar St" ];
>>       <city> "Cambridge";
>>       <state> "MA";
>>       <zip> 02139
>>    ]
>> ].
>> ==TO
>> [ a <Order>;
>>    <items> (
>>       [ <code> "4343"; <count> 1 ]
>>       [ <code> "4344"; <count> 2 ]
>>       [ <code> "4347"; <count> 3 ]
>>    );
>>    <shipTo> [
>>       a <Address>;
>>       <street> [ <num> 32; <name> "Vassar St" ];
>>       <city> "Cambridge";
>>       <state> "MA";
>>       <zip> 02139
>>    ];
>>    <billTo> [
>>       a <Address>;
>>       <street> [ <num> 36; <name> "Vassar St" ];
>>       <city> "Cambridge";
>>       <state> "MA";
>>       <zip> 02139
>>    ]
>> ].
>> ==END
>>
>>
>>
>> ==TEST 6
>> ==FROM
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 1
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 2
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 3
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 4
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 5
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 6
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 7
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 8
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 9
>> ]]]]]]]]].
>> ==TO
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 1
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 2
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 3
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 4
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 5
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 6
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 7
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 8
>> ]]]]]]]]].
>> <node> <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> [ <p> 0
>> ]]]]]]]]].
>> ==END
>>
>> ==TEST 7
>> ==FROM
>> _:x <a> _:y.
>> _:y <a> _:z.
>> _:z <a> _:x.
>> ==TO
>> _:x <a> _:y.
>> _:y <a> _:z.
>> _:x <a> _:z.
>> ==END
>>
>> ==TEST 8
>> ==FROM
>> <node> <p> [ <p> [ <p> [ <p> "1" ],
>>                         [ <p> "1" ]] ,
>>                   [ <p> [ <p> "1" ]]],
>>             [ <p> [ <p> [ <p> "1" ]  ,
>>                         [ <p> "1" ]],
>>             [ <p> [ <p> [ <p> "1" ]]].
>> ==TO
>> <node> <p> [ <p> [ <p> [ <p> "1" ],
>>                         [ <p> "1" ]] ,
>>                   [ <p> [ <p> "1" ]]],
>>             [ <p> [ <p> [ <p> "1" ]  ,
>>                         [ <p> "1" ], [ <p> "1" ],
>>             [ <p> [ <p> [ <p> "1" ]]].
>> ==END
>>
>>

Received on Tuesday, 12 August 2014 01:18:54 UTC