regarding sparql query

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

regarding sparql query

madhuri_gopal
Hi everyone,
 
   I am currently working on jena api and sparql.
   I am using the eclipse IDE for the java interface for ontology.
   I need to write a sparql query to retrieve the range and domain of all the properties in my ontology.
   In some cases , where the domain or range is theunion of 2 classes , i am getting a labeled node eg :_b0 ,:_b1.
   But, how do I find out the classes involved in the domain or range?
   Pls help me .Any suggestions would be really appreciated.
 
   Regards,
    Madhuri
 
 The code is:
  
   

public

static void main(String args[])

{ String inputFileName =

"c:\\Program Files\\Protege_3.4.1\\madhuri.owl";

Model model = ModelFactory.createDefaultModel();

InputStream in = FileManager.get().open( inputFileName );

if (in == null) {

throw new IllegalArgumentException( "File: " + inputFileName + " not found");

}

// read the RDF/XML file

model.read(in,

"");

String queryStr=

"PREFIX b: <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712#>" +

"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>" +

"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>" +

"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns>"+

"SELECT ?subject ?object WHERE { ?subject rdfs:domain ?object} "

;

execSelectQueryAndPrint( queryStr,System.

out,model);

}

public

static void execSelectQueryAndPrint(String queryStr, java.io.PrintStream outStream,Model model) {

// Create a new query

Query query = QueryFactory.create(queryStr);

// Execute the query and obtain results

QueryExecution qe = QueryExecutionFactory.create(query,model);

ResultSet results = qe.execSelect();

// Output query results

ResultSetFormatter.out(outStream, results, query);

// Important - free up resources used running the query

qe.close();

}

 

output is:

    

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

| subject | object |

======================================================================================================================================================================================

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasGestationalDiabetesMellitus> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasBrandName> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#InsulinTypes> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasHbAlcLevel> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasDrugs> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasMaxDosageInmg> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Types> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasDiabetesMellitus> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#has1HrPostPrandialGlucoseAdminConc> | _:b0 |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasPrediabetesMellitusWithValues> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#isCurrentlyTreatedPharmacologically> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasPlasmGlucoseConc> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#has2HrPostGlucoseAdmin> | _:b1 |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasFastingPlasmaGlucose> | _:b2 |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#has75GOralGlucoseToleranceTest> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasComposition> | _:b3 |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasReferenceRange> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasBrother> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasTestStates> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasInitialDosageInMg> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Types> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasOvertDM> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasSibling> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasDMDiagnosticCriteria> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#isNaiveToPharmacologicTherapy> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

question on properties at class level

Hayden Wimmer
i want to define a property at the class level so all instances of that
class inherit this property.

so if Class A has instances x, y, z i want to define a property such as
"hasMeatloaf" on Class A so class x hasMeatloaf, same with y and z

any advice?
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: regarding sparql query

Timothy Redmond
In reply to this post by madhuri_gopal
On 02/15/2011 07:41 AM, madhuri gopal wrote:
Hi everyone,
 
   I am currently working on jena api and sparql.
   I am using the eclipse IDE for the java interface for ontology.
   I need to write a sparql query to retrieve the range and domain of all the properties in my ontology.
   In some cases , where the domain or range is theunion of 2 classes , i am getting a labeled node eg :_b0 ,:_b1.
   But, how do I find out the classes involved in the domain or range?

This is really a jena question and as such you will have better luck on the jena mailing lists (jena.sourceforge.net).  I can tell you that you appear to be on the right track.  The class expression for the union class is an anonymous class.  If you get a single resource representing this class it will be an anonymous resource. The trick will be unraveling the structure of that anonymous resource to determine that it is a union class or whatever.

-Timothy


   Pls help me .Any suggestions would be really appreciated.
 
   Regards,
    Madhuri
 
 The code is:
  
   

public

static void main(String args[])

{ String inputFileName =

"c:\\Program Files\\Protege_3.4.1\\madhuri.owl";

Model model = ModelFactory.createDefaultModel();

InputStream in = FileManager.get().open( inputFileName );

if (in == null) { throw new IllegalArgumentException( <a class="moz-txt-link-rfc2396E" href="File:">"File: " + inputFileName + " not found");

}

// read the RDF/XML file

model.read(in,

"");

String queryStr=

"PREFIX b: <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712#>" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>" + "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns>"+

"SELECT ?subject ?object WHERE { ?subject rdfs:domain ?object} "

;

execSelectQueryAndPrint( queryStr,System.

out,model);

}

public

static void execSelectQueryAndPrint(String queryStr, java.io.PrintStream outStream,Model model) { // Create a new query

Query query = QueryFactory.create(queryStr);

// Execute the query and obtain results

QueryExecution qe = QueryExecutionFactory.create(query,model);

ResultSet results = qe.execSelect();

// Output query results

ResultSetFormatter.out(outStream, results, query);

// Important - free up resources used running the query

qe.close();

}

 

output is:

    

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

| subject | object |

======================================================================================================================================================================================

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasGestationalDiabetesMellitus> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasBrandName> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#InsulinTypes> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasHbAlcLevel> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasDrugs> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasMaxDosageInmg> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Types> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasDiabetesMellitus> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#has1HrPostPrandialGlucoseAdminConc> | _:b0 |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasPrediabetesMellitusWithValues> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#isCurrentlyTreatedPharmacologically> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasPlasmGlucoseConc> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#has2HrPostGlucoseAdmin> | _:b1 |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasFastingPlasmaGlucose> | _:b2 |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#has75GOralGlucoseToleranceTest> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasComposition> | _:b3 |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasReferenceRange> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasBrother> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasTestStates> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasInitialDosageInMg> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Types> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasOvertDM> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasSibling> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#hasDMDiagnosticCriteria> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

| <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#isNaiveToPharmacologicTherapy> | <http://www.owl-ontologies.com/2011/1/1/Ontology1293884712.owl#Person> |

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: regarding sparql query

Olivier Dameron
In reply to this post by madhuri_gopal
Hello,

On 02/15/2011 04:41 PM, madhuri gopal wrote:
>     I need to write a sparql query to retrieve the range and domain of
> all the properties in my ontology.
>     In some cases , where the domain or range is theunion of 2 classes ,
> i am getting a labeled node eg :_b0 ,:_b1.
>     But, how do I find out the classes involved in the domain or range?

Test if ?object is rdf:type owl:unionOf and proceed from there to
retrieve the two classes using owl rdf representation.

Note: this is potentially a difficult problem, as the classes involved
in the union can themselves be composed... enjoy :-)

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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: question on properties at class level

Timothy Redmond
In reply to this post by Hayden Wimmer
On 02/15/2011 07:43 AM, Hayden Wimmer wrote:
i want to define a property at the class level so all instances of that class inherit this property.

so if Class A has instances x, y, z i want to define a property such as "hasMeatloaf" on Class A so class x hasMeatloaf, same with y and z

If you add a necessary condition to the class of the form

ClassA SubClassOf hasMeatloaf some Thing

then it will follow that for all individuals in ClassA there is some hasMeatloaf value.

-Timothy


    

any advice?
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: regarding sparql query

Olivier Dameron
In reply to this post by madhuri_gopal
On 02/15/2011 04:41 PM, madhuri gopal wrote:
>     I am currently working on jena api and sparql.
>     I am using the eclipse IDE for the java interface for ontology.
>     I need to write a sparql query to retrieve the range and domain of
> all the properties in my ontology.
>     In some cases , where the domain or range is theunion of 2 classes ,
> i am getting a labeled node eg :_b0 ,:_b1.
>     But, how do I find out the classes involved in the domain or range?

On second thought, you could try to use SQWRL
(http://protege.cim3.net/cgi-bin/wiki.pl?SQWRL) although you may need to
push it to its limits

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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: question on properties at class level

Hayden Wimmer
In reply to this post by Timothy Redmond
tim

i don't think i explained well enough.

here is a sample triple

Class A hasFriend ClassB

in this case i want ALL instances of class A to hasFriend all instances of ClassB

so if ClassA has instances a and b and ClassB has instances x and y then

a hasFriend x
a hasFriend y
b hasFriend x
b hasFriend y

i do not know how to assign the property to the class...



On 2/15/2011 12:09 PM, Timothy Redmond wrote:
On 02/15/2011 07:43 AM, Hayden Wimmer wrote:
i want to define a property at the class level so all instances of that class inherit this property.

so if Class A has instances x, y, z i want to define a property such as "hasMeatloaf" on Class A so class x hasMeatloaf, same with y and z

If you add a necessary condition to the class of the form

ClassA SubClassOf hasMeatloaf some Thing

then it will follow that for all individuals in ClassA there is some hasMeatloaf value.

-Timothy



any advice?
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: question on properties at class level

Timothy Redmond
On 02/15/2011 10:00 AM, Hayden Wimmer wrote:
tim

i don't think i explained well enough.

here is a sample triple

Class A hasFriend ClassB

in this case i want ALL instances of class A to hasFriend all instances of ClassB

Your triple won't say what you want.

so if ClassA has instances a and b and ClassB has instances x and y then

a hasFriend x
a hasFriend y
b hasFriend x
b hasFriend y

i do not know how to assign the property to the class...

I don't immediately know how to say this in OWL.   I can say some related things.

ClassA SubClassOf hasFriend some ClassB

says that any individual in ClassA has a friend in ClassB.  You could then add the other direction


ClassB SubClassOf inverse(hasFriend) some ClassA

which says that any individual in ClassB is a friend of some individual in ClassA.  But this doesn't add up to what you requested.  I am not sure if it is possible.

-Timothy





On 2/15/2011 12:09 PM, Timothy Redmond wrote:
On 02/15/2011 07:43 AM, Hayden Wimmer wrote:
i want to define a property at the class level so all instances of that class inherit this property.

so if Class A has instances x, y, z i want to define a property such as "hasMeatloaf" on Class A so class x hasMeatloaf, same with y and z

If you add a necessary condition to the class of the form

ClassA SubClassOf hasMeatloaf some Thing

then it will follow that for all individuals in ClassA there is some hasMeatloaf value.

-Timothy



any advice?
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: question on properties at class level

Hayden Wimmer
is there a way to do this with jena or swrl rules?

On Tue, Feb 15, 2011 at 1:56 PM, Timothy Redmond <[hidden email]> wrote:
On 02/15/2011 10:00 AM, Hayden Wimmer wrote:
tim

i don't think i explained well enough.

here is a sample triple

Class A hasFriend ClassB

in this case i want ALL instances of class A to hasFriend all instances of ClassB

Your triple won't say what you want.

so if ClassA has instances a and b and ClassB has instances x and y then

a hasFriend x
a hasFriend y
b hasFriend x
b hasFriend y

i do not know how to assign the property to the class...

I don't immediately know how to say this in OWL.   I can say some related things.

ClassA SubClassOf hasFriend some ClassB

says that any individual in ClassA has a friend in ClassB.  You could then add the other direction


ClassB SubClassOf inverse(hasFriend) some ClassA

which says that any individual in ClassB is a friend of some individual in ClassA.  But this doesn't add up to what you requested.  I am not sure if it is possible.

-Timothy





On 2/15/2011 12:09 PM, Timothy Redmond wrote:
On 02/15/2011 07:43 AM, Hayden Wimmer wrote:
i want to define a property at the class level so all instances of that class inherit this property.

so if Class A has instances x, y, z i want to define a property such as "hasMeatloaf" on Class A so class x hasMeatloaf, same with y and z

If you add a necessary condition to the class of the form

ClassA SubClassOf hasMeatloaf some Thing

then it will follow that for all individuals in ClassA there is some hasMeatloaf value.

-Timothy



any advice?
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03



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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: question on properties at class level

Thomas Russ
Like Timothy Redmond, I also can't think of a way to write the  
constraint using just OWL constructs.

On Feb 15, 2011, at 11:44 AM, Hayden Wimmer wrote:

> is there a way to do this with jena

Probably.  But I don't use the Jena interface, so I can't give any  
example.

> or swrl rules?

Yes, you can write this fairly easily with SWRL Rules:

   ClassA(?a) ^ ClassB(?b) -> hasFriend(?a, ?b) ^ hasFriend(?b, ?a)

Actually, if you may hasFriend be a SymmetricProperty, then you should  
only have to assert one of the two property relations.

Note that this will give you |ClassA| x |ClassB| property pairs.

> On Tue, Feb 15, 2011 at 1:56 PM, Timothy Redmond <[hidden email]
> > wrote:
> On 02/15/2011 10:00 AM, Hayden Wimmer wrote:
>>
>> tim
>>
>> i don't think i explained well enough.
>>
>> here is a sample triple
>>
>> Class A hasFriend ClassB
>>
>> in this case i want ALL instances of class A to hasFriend all  
>> instances of ClassB
>
> Your triple won't say what you want.
>
>> so if ClassA has instances a and b and ClassB has instances x and y  
>> then
>>
>> a hasFriend x
>> a hasFriend y
>> b hasFriend x
>> b hasFriend y
>>
>> i do not know how to assign the property to the class...
>
> I don't immediately know how to say this in OWL.   I can say some  
> related things.
>
> ClassA SubClassOf hasFriend some ClassB
>
> says that any individual in ClassA has a friend in ClassB.  You  
> could then add the other direction
>
>
> ClassB SubClassOf inverse(hasFriend) some ClassA
>
> which says that any individual in ClassB is a friend of some  
> individual in ClassA.  But this doesn't add up to what you  
> requested.  I am not sure if it is possible.
>
> -Timothy
>
>
>>
>>
>>
>> On 2/15/2011 12:09 PM, Timothy Redmond wrote:
>>>
>>> On 02/15/2011 07:43 AM, Hayden Wimmer wrote:
>>>>
>>>> i want to define a property at the class level so all instances  
>>>> of that class inherit this property.
>>>>
>>>> so if Class A has instances x, y, z i want to define a property  
>>>> such as "hasMeatloaf" on Class A so class x hasMeatloaf, same  
>>>> with y and z
>>>
>>> If you add a necessary condition to the class of the form
>>>
>>> ClassA SubClassOf hasMeatloaf some Thing
>>>
>>> then it will follow that for all individuals in ClassA there is  
>>> some hasMeatloaf value.
>>>
>>> -Timothy
>>>
>>>
>>>>
>>>> any advice?
>>>> _______________________________________________
>>>> protege-owl mailing list
>>>> [hidden email]
>>>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>>>
>>>> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>>>
>>>
>>> _______________________________________________
>>> protege-owl mailing list
>>> [hidden email]
>>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>>
>>> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>>
>> _______________________________________________
>> protege-owl mailing list
>> [hidden email]
>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>
>> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>
>
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>
>
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: question on properties at class level

Timothy Redmond
In reply to this post by Hayden Wimmer
On 02/15/2011 11:44 AM, Hayden Wimmer wrote:
is there a way to do this with jena or swrl rules?

The Jena part is the wrong question.  Jena is a technology for working with a language like RDF or OWL.   The question you want is whether the ontology languages can state this.  RDF has no chance - RDF is extremely inexpressive compared to OWL.

SWRL will work though.  You can write a rule like (excuse any problems with syntax)

ClassA(?x) and ClassB(?y) -> hasFriend(?x, ?y)


-Timothy


On Tue, Feb 15, 2011 at 1:56 PM, Timothy Redmond <[hidden email]> wrote:
On 02/15/2011 10:00 AM, Hayden Wimmer wrote:
tim

i don't think i explained well enough.

here is a sample triple

Class A hasFriend ClassB

in this case i want ALL instances of class A to hasFriend all instances of ClassB

Your triple won't say what you want.

so if ClassA has instances a and b and ClassB has instances x and y then

a hasFriend x
a hasFriend y
b hasFriend x
b hasFriend y

i do not know how to assign the property to the class...

I don't immediately know how to say this in OWL.   I can say some related things.

ClassA SubClassOf hasFriend some ClassB

says that any individual in ClassA has a friend in ClassB.  You could then add the other direction


ClassB SubClassOf inverse(hasFriend) some ClassA

which says that any individual in ClassB is a friend of some individual in ClassA.  But this doesn't add up to what you requested.  I am not sure if it is possible.

-Timothy





On 2/15/2011 12:09 PM, Timothy Redmond wrote:
On 02/15/2011 07:43 AM, Hayden Wimmer wrote:
i want to define a property at the class level so all instances of that class inherit this property.

so if Class A has instances x, y, z i want to define a property such as "hasMeatloaf" on Class A so class x hasMeatloaf, same with y and z

If you add a necessary condition to the class of the form

ClassA SubClassOf hasMeatloaf some Thing

then it will follow that for all individuals in ClassA there is some hasMeatloaf value.

-Timothy



any advice?
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03