Re: [shex] Blank node behavior when using SPARQL (#109)

I'm currently adding both arrival path and disambiguation code in the ShEx.js SPARQL interface. This allows it to:
1. remember how it got to some bnodes
2. distinguish all of the bnodes from each other.

Wikidata (augmented) example:

``` turtle
wd:Q313093 <P999> _:a .
_:a
  # works
  <P2860> _:a ; # apparenlty, a bare blank node stands for unknown value
  # advisors
  <P184> wd:Q123 , _:1e_____ , _:xe_____ , _:ye_____ , _:1cd__2g , _:1cd__2f , _:1cdef2g , _:1cdef2f .

# advisors (mostly bnodes to exercise disambiguator)
wd:Q123                                                         <P735> "a" , "b" .
_:1e_____ <P000> wd:Qe                                        ; <P735> "abc" .
_:xe_____ <P000> wd:Qe                                        ; <P735> "abc" .
_:ye_____ <P000> wd:Qe                                        ; <P735> "abc" .
_:1cd__2g <P000> wd:Qc , wd:Qd                 ; <P001> wd:Qg ; <P735> "abc" .
_:1cd__2f <P000> wd:Qc , wd:Qd                 ; <P001> wd:Qf ; <P735> "abc" .
_:1cdef2g <P000> wd:Qc , wd:Qd , wd:Qe , wd:Qf ; <P001> wd:Qg ; <P735> "abc" .
_:1cdef2f <P000> wd:Qc , wd:Qd , wd:Qe , wd:Qf ; <P001> wd:Qf ; <P735> "abc" .
```

The data structure is (JSON liberalized to include RDF terms) to identify e.g. `_:1cdef2g` is
``` turtle
{ start: wd:Q313093, path: [
  {p:<P999>}, # no ambiguity
  {p:<P184>, unique: {
     <P000>: [wd:Qc, wd:Qd],
    <P001> = [wd:Qg]
   }
]
```
which allows you to select for `_:1cdef2g` ?p ?o like:
``` sparql
SELECT ?1 ?p ?o WHERE {
  wd:Q313093 <P999> ?0 . # no ambiguity
  ?0 <P184> ?1 .
  ?1 <P000> wd:Qc , wd:Qd . ?1 <P001> wd:Qg . # disambuate
 FILTER NOT EXISTS {?1 <P000> ?2 FILTER (NOT (?2 IN (wd:Qc, wd:Qg)) }
  ?1 ?p ?o
}
```

`_:1e_____`, `_:xe_____` , and `_:ye_____` are provably interchangeable so the data structure for the former needs to indidate that it's serving for three:
``` turtle
{ start: wd:Q313093, path: [
  {p:<P999>}, # no ambiguity
  {p:<P184>, unique: {
     <P001> = [wd:Qe]
    }, proxies: [ _:xe_____ , _:ye_____ ]
  }
]
```
and `_:xe_____` , and `_:ye_____` simply execute the query for `_:1e_____`.

I haven't tested for corefs, which would be another way to disambiguate AND might prove that 1e, xe and ye aren't all interchangable, but we'd only have to do those tests iff the schema included inverse arcs in the right places.


-- 
GitHub Notification of comment by ericprud
Please view or discuss this issue at https://github.com/shexSpec/shex/issues/109#issuecomment-731049091 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 20 November 2020 09:19:22 UTC