UNSAID in SPARQL Query

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

UNSAID in SPARQL Query

sizedam
Would be grateful if someone could help me debug this SPARQL query. I want to see all triples pertaining to subject 'productName' except those where predicate is simply 'rdf:type'. Getting error:

Encountered: " " (32), after: "UNSAID"

PREFIX myOnt: <http://www.someSite.com/myOnt#>
SELECT ?relationship ?object
        WHERE { myOnt:productName  ?relationship ?object .
                              UNSAID {myOnt:productName rdf:type ?object .}

Also, how to examine logs for more detail?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: UNSAID in SPARQL Query

Dave McComb-2
I think you meant MINUS instead of UNSAID and you need an extra } at the end to close the WHERE {

> On Apr 11, 2017, at 6:54 AM, sizedam <[hidden email]> wrote:
>
> Would be grateful if someone could help me debug this SPARQL query. I want to
> see all triples pertaining to subject 'productName' except those where
> predicate is simply 'rdf:type'. Getting error:
>
> Encountered: " " (32), after: "UNSAID"
>
> PREFIX myOnt: <http://www.someSite.com/myOnt#>
> SELECT ?relationship ?object
> WHERE { myOnt:productName  ?relationship ?object .
>                              UNSAID {myOnt:productName rdf:type ?object .}
>
> Also, how to examine logs for more detail?
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/UNSAID-in-SPARQL-Query-tp4668098.html
> Sent from the Protege User mailing list archive at Nabble.com.
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: UNSAID in SPARQL Query

sizedam
Thank you Dave, that worked. Got too many results though; I'd have to use composite MINUS statements to drill into the 2 or 3 predicates of interest.

So how would I do the opposite, i.e. return ONLY those triplets with predicates of interest? I tried FILTER but got error:

Encountered " <PNAME_LN> "myOnt:category " ... was expecting ... and then a bunch of operators, so I guess FILTER is more for data properties.

PREFIX myOnt: <http://www.someSite.com/myOnt#>
SELECT ?relationship ?object
WHERE { myOnt:product  ?relationship ?object .
               FILTER (myOnt:productName myOnt:Category ?object) .}

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: UNSAID in SPARQL Query

Dave McComb-2
Filter generally has a test of some sort.

for instance FILTER (?object IN (myOnt:Category))

Not sure what you’re trying to do here though


> On Apr 11, 2017, at 10:05 AM, sizedam <[hidden email]> wrote:
>
> Thank you Dave, that worked. Got too many results though; I'd have to use
> composite MINUS statements to drill into the 2 or 3 predicates of interest.
>
> So how would I do the opposite, i.e. return ONLY those triplets with
> predicates of interest? I tried FILTER but got error:
>
> Encountered " <PNAME_LN> "myOnt:category " ... was expecting ... and then a
> bunch of operators, so I guess FILTER is more for data properties.
>
> PREFIX myOnt: <http://www.someSite.com/myOnt#>
> SELECT ?relationship ?object
> WHERE { myOnt:product  ?relationship ?object .
>               FILTER (myOnt:productName myOnt:Category ?object) .}
>
>
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/UNSAID-in-SPARQL-Query-tp4668098p4668103.html
> Sent from the Protege User mailing list archive at Nabble.com.
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: UNSAID in SPARQL Query

sizedam
That makes sense. My goal is to see all the triplets which have a certain set of custom predicates; in other words I don't want to see any standard RDF/OWL predicates. I got a little further using the EXISTS condition for 1 predicate pattern, but am stuck on how add more patterns.

This works:

SELECT ?subject ?relationship ?object
        WHERE { ?subject ?relationship ?object .
                              FILTER (
                                    EXISTS {
                                         ?subject  myOnt:hasCategory ?object . }
                                         ) }

But this returns NO results. I guess it's AND'g? How can I make it OR?

SELECT ?subject ?relationship ?object
        WHERE { ?subject ?relationship ?object .
                              FILTER (
                                    EXISTS {
                                         ?subject  myOnt:hasCategory ?object .
                                         ?subject  myOnt:hasVendor ?object . }
                                         ) }
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: UNSAID in SPARQL Query

Dave McComb-2
Several simpler approaches

SELECT ?subject ?object
WHERE {
?subject (:rel1 | :rel2 | :rel3) ?object

}

or

SELECT ?subject ?object
WHERE {
OPTIONAL {?subject :rel1 ?object}
OPTIONAL {?subject :rel2 ?object}
OPTIONAL {?subject :rel3 ?object}
}

or

SELECT ?subject ?pred ?object
WHERE {
?subject ?pred ?objet .
FILTER (?pred IN (:rel1 , :rel2 , :rel3))
}


> On Apr 11, 2017, at 10:43 AM, sizedam <[hidden email]> wrote:
>
> That makes sense. My goal is to see all the triplets which have a certain set
> of custom predicates; in other words I don't want to see any standard
> RDF/OWL predicates. I got a little further using the EXISTS condition for 1
> predicate pattern, but am stuck on how add more patterns.
>
> This works:
>
> SELECT ?subject ?relationship ?object
> WHERE { ?subject ?relationship ?object .
>                              FILTER (
>                                    EXISTS {
>                                         ?subject  myOnt:hasCategory ?object
> . }
>                                         ) }
>
> But this returns NO results. I guess it's AND'g? How can I make it OR?
>
> SELECT ?subject ?relationship ?object
> WHERE { ?subject ?relationship ?object .
>                              FILTER (
>                                    EXISTS {
>                                         ?subject  myOnt:hasCategory ?object
> .
>                                         ?subject  myOnt:hasVendor ?object .
> }
>                                         ) }
>
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/UNSAID-in-SPARQL-Query-tp4668098p4668105.html
> Sent from the Protege User mailing list archive at Nabble.com.
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: UNSAID in SPARQL Query

sizedam
Thanks so much Dave! Your third suggestion (using FILTER with IN) did the trick!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: UNSAID in SPARQL Query

Lorenz Buehmann
I really suggest you to have a look at the SPARQL specs. [1]
It looks like you randomly use some language constructs that do not
exists. For instance, form where do you had the keyword UNSAID?

[1] https://www.w3.org/TR/sparql11-query/

> Thanks so much Dave! Your third suggestion (using FILTER with IN) did the
> trick!
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/UNSAID-in-SPARQL-Query-tp4668098p4668114.html
> Sent from the Protege User mailing list archive at Nabble.com.
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: UNSAID in SPARQL Query

sizedam
Lorenz - I first learned about UNSAID in “Semantic Web for the Working Ontologist” by Dean Allemang & Jim Hendler, copyright 2011. The reference is in Chapter 5, p.84 in a section titled “Negation (SPARQL 1.1)”.

Thank you for pointing out that UNSAID is not in the W3C’s latest Recommendation for SPARQL 1.1 (Mar 21, 2013). I found what seems to be an orphaned W3C Feature description for UNSAID which states that “This wish was closed with a resolution not to address in the last REC” with a link off to an Issues List which in turn had a link off to minutes from a Working Group Meeting in Helsinki in 2005 where it seems UNSAID was rejected in favor of the ‘bound’ operator in conjunction with OPTIONAL clauses.

Given that its rejection dates back to 2005, it is surprising that UNSAID made it into a 2011 printed publication.

Links:
https://www.w3.org/2009/sparql/wiki/Feature:Negation
https://www.w3.org/2001/sw/DataAccess/issues#unsaid
https://www.w3.org/2001/sw/DataAccess/ftf4.html#item04

Lorenz B. wrote
I really suggest you to have a look at the SPARQL specs. [1]
It looks like you randomly use some language constructs that do not
exists. For instance, form where do you had the keyword UNSAID?

[1] https://www.w3.org/TR/sparql11-query/
> Thanks so much Dave! Your third suggestion (using FILTER with IN) did the
> trick!
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/UNSAID-in-SPARQL-Query-tp4668098p4668114.html
> Sent from the Protege User mailing list archive at Nabble.com.
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Loading...