How to FILTER the output?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to FILTER the output?

Andre Luiz Tietbohl Ramos
Hello,

I need to restrict matching among the results of the query below:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?design_tolerance ?machine_tolerance
WHERE { ?design_tolerance rdfs:subClassOf <http://jade.cselt.it/beangenerator#DesignedTolerance> .
                    ?machine_tolerance rdfs:subClassOf <http://jade.cselt.it/beangenerator#MachineMfgmit>  . }

The output the the complete matching set from this query is 4 however I want only the results shown: 2.

DesignedLowerLimit             MfgLowerLimit
DesignedUpperLimit             MfgUpperLimit

Is there any way to accomplish this? A FILTER perhaps?

TIA

--
Andre Luiz Tietbohl Ramos <[hidden email]>

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

Re: How to FILTER the output?

Csongor Nyulas-2
Administrator
I guess what you want is:
SELECT DISTINCT ?design_tolerance ?machine_tolerance
....

Csongor

On 04/08/2015 04:55 PM, Andre Luiz Tietbohl Ramos wrote:
Hello,

I need to restrict matching among the results of the query below:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?design_tolerance ?machine_tolerance
WHERE { ?design_tolerance rdfs:subClassOf <http://jade.cselt.it/beangenerator#DesignedTolerance> .
                    ?machine_tolerance rdfs:subClassOf <http://jade.cselt.it/beangenerator#MachineMfgmit>  . }

The output the the complete matching set from this query is 4 however I want only the results shown: 2.

DesignedLowerLimit             MfgLowerLimit
DesignedUpperLimit             MfgUpperLimit

Is there any way to accomplish this? A FILTER perhaps?

TIA

--
Andre Luiz Tietbohl Ramos <[hidden email]>


_______________________________________________
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
|

Re: How to FILTER the output?

Andre Luiz Tietbohl Ramos
In reply to this post by Andre Luiz Tietbohl Ramos
Dear Csongor,

Thanks for the quick reply but your suggestion does not accomplish what I need. With or without the DISTINCT keyword the answer is the cartesian product among the query components and I want it not to happen.

TIA

On Qui, 2015-04-09 at 12:03 -0700, [hidden email] wrote:

Message: 19
Date: Wed, 08 Apr 2015 20:04:22 -0700
From: Csongor Nyulas <[hidden email]>
To: User support for WebProtege and Protege Desktop
	<[hidden email]>
Subject: Re: [protege-user] How to FILTER the output?
Message-ID: <[hidden email]>
Content-Type: text/plain; charset="windows-1252"; Format="flowed"

I guess what you want is:
SELECT *DISTINCT* ?design_tolerance ?machine_tolerance
....

Csongor

On 04/08/2015 04:55 PM, Andre Luiz Tietbohl Ramos wrote:
> Hello,
>
> I need to restrict matching among the results of the query below:
>
> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> PREFIX owl: <http://www.w3.org/2002/07/owl#>
> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>
> SELECT ?design_tolerance ?machine_tolerance
> WHERE { ?design_tolerance rdfs:subClassOf 
> <http://jade.cselt.it/beangenerator#DesignedTolerance> .
>                     ?machine_tolerance rdfs:subClassOf 
> <http://jade.cselt.it/beangenerator#MachineMfgmit 
> <http://jade.cselt.it/beangenerator#MachineMfgLimit>> . }
>
> The output the the complete matching set from this query is 4 however 
> I want only the results shown: 2.
>
> DesignedLowerLimit             MfgLowerLimit
> DesignedUpperLimit             MfgUpperLimit
>
> Is there any way to accomplish this? A FILTER perhaps?

--
Andre Luiz Tietbohl Ramos <[hidden email]>

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

Re: How to FILTER the output?

Rafael Gonçalves
In reply to this post by Andre Luiz Tietbohl Ramos
Hi Andre,

Yes, you can filter out SPARQL query results using FILTER. However, it is unclear which results you want or don’t want. Also, without the relevant axioms it’s hard to say precisely how the query could be changed to accomplish your goal. So which 2 results do you want to receive?

Cheers,
Rafael

On Apr 8, 2015, at 16:55, Andre Luiz Tietbohl Ramos <[hidden email]> wrote:

Hello,

I need to restrict matching among the results of the query below:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?design_tolerance ?machine_tolerance
WHERE { ?design_tolerance rdfs:subClassOf <http://jade.cselt.it/beangenerator#DesignedTolerance> .
                    ?machine_tolerance rdfs:subClassOf <http://jade.cselt.it/beangenerator#MachineMfgmit>  . }

The output the the complete matching set from this query is 4 however I want only the results shown: 2.

DesignedLowerLimit             MfgLowerLimit
DesignedUpperLimit             MfgUpperLimit

Is there any way to accomplish this? A FILTER perhaps?

TIA

--
Andre Luiz Tietbohl Ramos <[hidden email]>
_______________________________________________
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
|

Re: How to FILTER the output?

Andre Luiz Tietbohl Ramos
In reply to this post by Andre Luiz Tietbohl Ramos
Hello Rafael,

Thanks for the response. Regarding you reply, I can outline that I don't want the cartesian product of all the possible alternatives.  The query related two different classes: DesignedTolerance (it has two subclasses DesignedLowerLimit and DesignedUpperLimit) and MachineMfgLimit (it has two subclasses as well: MfgLowerLimit, MfgUpperLimit). The objective is to show that the designed tolerances must conform with machine ones. The query below attemps to do that. Unfortunately it returns all the answers.

SELECT ?design_tolerance ?test
WHERE { ?design_tolerance rdfs:subClassOf <http://jade.cselt.it/beangenerator#DesignedTolerance> .
              ?test rdfs:subClassOf <http://jade.cselt.it/beangenerator#MachineMfgLimit> . }

The answer I'm looking for is,

DesignedLowerLimit             MfgLowerLimit
DesignedUpperLimit            MfgUpperLimit

I tried to solve it through a property as well to no avail but it may be my problem in this case. Could you help to solve it?

TIA


>Message: 5
>Date: Thu, 9 Apr 2015 14:35:10 -0700
>From: Rafael Goncalves <[hidden email]>
>To: User support for WebProtege and Protege Desktop
>        <[hidden email]>
>Subject: Re: [protege-user] How to FILTER the output?
>Message-ID: <[hidden email]>
>Content-Type: text/plain; charset="utf-8"

>Hi Andre,

>Yes, you can filter out SPARQL query results using FILTER. However, it is unclear which results you want or don?t want. Also, without the >relevant axioms it?s hard to say precisely how the query could be changed to accomplish your goal. So which 2 results do you want to >receive?

>Cheers,
>Rafael


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

Re: How to FILTER the output?

Rafael Gonçalves
Hi Andre,

In order to understand why you’re getting these answers and not the ones you want, it might be a good idea to revise how SPARQL works. Meanwhile, I’ll try and walk you through the way your query is answered: first it finds a subclass of DesignedTolerance, let’s say DesignedLowerLimit; now DesignedLowerLimit is one possible replacement for variable ?design_tolerance. Then in the second graph matching condition the query finds a subclass of MachineMfgLimit called MfgLowerLimit; now MfgLowerLimit is one possible replacement for variable ?test. This forms 1 result. Here’s another result: we instantiate ?design_tolerance with DesignedLowerLimit and ?test with MfgUpperLimit. That’s 2 results now. Now do the same with DesignedUpperLimit as the replacement for ?designed_tolerance and you get another 2 results. Do you understand now why you’re getting those 4 results?

Beyond that, I can’t tell you precisely how to modify the query (and/or ontology) to get the right results, unless you provide us with the ontology, relevant axioms, or some indication as to how the DesignedTolerance and the MachineMfgLimit classes are modeled. Could you send us that?

Hope this helps!

Cheers,
Rafael

On Apr 10, 2015, at 13:29, Andre Luiz Tietbohl Ramos <[hidden email]> wrote:

Hello Rafael,

Thanks for the response. Regarding you reply, I can outline that I don't want the cartesian product of all the possible alternatives.  The query related two different classes: DesignedTolerance (it has two subclasses DesignedLowerLimit and DesignedUpperLimit) and MachineMfgLimit (it has two subclasses as well: MfgLowerLimit, MfgUpperLimit). The objective is to show that the designed tolerances must conform with machine ones. The query below attemps to do that. Unfortunately it returns all the answers.

SELECT ?design_tolerance ?test
WHERE { ?design_tolerance rdfs:subClassOf <http://jade.cselt.it/beangenerator#DesignedTolerance> .
              ?test rdfs:subClassOf <http://jade.cselt.it/beangenerator#MachineMfgLimit> . }

The answer I'm looking for is,

DesignedLowerLimit             MfgLowerLimit
DesignedUpperLimit            MfgUpperLimit

I tried to solve it through a property as well to no avail but it may be my problem in this case. Could you help to solve it?

TIA


>Message: 5
>Date: Thu, 9 Apr 2015 14:35:10 -0700
>From: Rafael Goncalves <[hidden email]>
>To: User support for WebProtege and Protege Desktop
>        <[hidden email]>
>Subject: Re: [protege-user] How to FILTER the output?
>Message-ID: <[hidden email]>
>Content-Type: text/plain; charset="utf-8"

>Hi Andre,

>Yes, you can filter out SPARQL query results using FILTER. However, it is unclear which results you want or don?t want. Also, without the >relevant axioms it?s hard to say precisely how the query could be changed to accomplish your goal. So which 2 results do you want to >receive?

>Cheers,
>Rafael

_______________________________________________
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
|

Re: How to FILTER the output?

Andre Luiz Tietbohl Ramos
In reply to this post by Andre Luiz Tietbohl Ramos
Hello Rafael,

>Yes, you can filter out SPARQL query results using FILTER. However, it
> is unclear which results you want or don?t want. Also, without the
>relevant axioms it?s hard to say precisely how the query could be
> changed to accomplish your goal. So which 2 results do you want to
>receive?

The answers I want are the ones below:

On Sáb, 2015-04-11 at 12:02 -0700, [hidden email] wrote:
DesignedLowerLimit            MfgLowerLimit
DesignedUpperLimit            MfgUpperLimit

The ones I get after the query are its cartesian product:

DesignedLowerLimit            MfgLowerLimit
DesignedUpperLimit            MfgUpperLimit
DesignedLowerLimit            MfgUpperLimit
DesignedUpperLimit            MfgLowerLimit

Thus, I guess what I need is to FILTER by the type of limit: upper or lower? Perhaps, I could define a disjunction between DesignedLowerLimit and MfgUpperLimit, DesignedUpperLimit and MfgLowerLimit?

Best,

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

Re: How to FILTER the output?

Csongor Nyulas-2
Administrator
Andre,
do you have any properties in your ontology (like for example for the type of the limit)? Do you have any restrictions on your classes that the SPARQL query can exploit to filter the results? We can't really help you if we don't see your ontology, or at least the relevant axioms.

Csongor

On 04/11/2015 01:39 PM, Andre Luiz Tietbohl Ramos wrote:
Hello Rafael,

>Yes, you can filter out SPARQL query results using FILTER. However, it
> is unclear which results you want or don?t want. Also, without the
>relevant axioms it?s hard to say precisely how the query could be
> changed to accomplish your goal. So which 2 results do you want to
>receive?

The answers I want are the ones below:

On Sáb, 2015-04-11 at 12:02 -0700, [hidden email] wrote:
DesignedLowerLimit            MfgLowerLimit
DesignedUpperLimit            MfgUpperLimit

The ones I get after the query are its cartesian product:

DesignedLowerLimit            MfgLowerLimit
DesignedUpperLimit            MfgUpperLimit
DesignedLowerLimit            MfgUpperLimit
DesignedUpperLimit            MfgLowerLimit

Thus, I guess what I need is to FILTER by the type of limit: upper or lower? Perhaps, I could define a disjunction between DesignedLowerLimit and MfgUpperLimit, DesignedUpperLimit and MfgLowerLimit?

Best,

Andre Luiz

_______________________________________________
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