Search Mailing List Archives

Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-owl] using the protege owl api

Timothy Redmond tredmond at
Fri Apr 20 16:56:06 PDT 2007

All of these questions have underlying assumptions about what level  
of inference you want.  I will assume that you are talking about a  
very basic level of inference that comes from direct inspection of  
the statements in the owl file without running anything like a reasoner.

On Apr 20, 2007, at 4:18 AM, maali ben khedija wrote:

> hi
> I'm using the protege-owl api
> My questions are:
>     -how can i get  the list of property in which a given class is  
> in the range of this property

So it sounds like, given a class C,  you are asking for all  
properties, p, where p has range X

       <p , range, X>

and C is a subclass of X.  I don't know of a direct call for this.   
If you had instead been asking for the properties whose domain  
contains C you could use


But it is not hard to get code to do this:

    private static Set<OWLObjectProperty> getPropertiesWithRange 
(OWLNamedClass cls) {
         OWLModel om = cls.getOWLModel();
         Set<OWLObjectProperty> result = new  
         for (Object o : om.getUserDefinedOWLObjectProperties()) {
             if (o instanceof OWLObjectProperty) {
                 OWLObjectProperty p = (OWLObjectProperty) o;
                 for (Object o1 : p.getUnionRangeClasses()) {
                     if (o1 instanceof RDFSClass) {
                         RDFSClass range_cls = (RDFSClass) o1;
                         if (cls.isSubclassOf(range_cls)) {
                             System.out.println("Found " +  
p.getBrowserText() +
                                     " because " + cls.getBrowserText 
() +
                                     " is a subclass of " +  
         return result;

If p has range B and C is a subclass of B then getPropertiesWithRange 
(C) prints

	Found p because C is a subclass of B

There may be an easier way.

>     -how can i get the list of properties which are in the  
> restrictions of a given class

Here, given a class A,  I assume that you are asking for all  
properties such that

	A \subseteq Restriction r

and p is the onProperty value of the restriction r.  You can get this  
with the code

     private static Set<RDFProperty> getRestrictionProperties 
(OWLNamedClass c) {
         System.out.println("Getting restriction properties for " +  
         Set<RDFProperty> properties = new HashSet<RDFProperty>();
         for (Object o : c.getRestrictions()) {
             if (o instanceof OWLRestriction) {
                 OWLRestriction r = (OWLRestriction) o;
                 RDFProperty p = r.getOnProperty();
                 System.out.println("Found " + p.getBrowserText() + "  
in the restriction " + r.getBrowserText());
         return properties;

If you make an ontology where

	A \subseteq (p some C)
	A \subseteq (q only C)

then this routine will print

Getting restriction properties for A
Found q in the restriction q only C
Found p in the restriction p some C

I think that this should give you an idea how to proceed.  I would  
recommend working through the developer documentation for OWL:


>     -how can i get the list of classes which are in the range  of  
> given properties and range
>       (eg:    the domain of the property has_rights  is: employers,  
> students, women , man...
>                the range of the property has_rights is : article1,  
> article2, article3
>                the class employers has like restriction: has_rights  
> allVAluesfrom article1
>                the class employers has like restriction: has_rights  
> allVAluesFrom article2
>                 ...
>             my question is how to get article1 as result when i  
> give employers as the domain of the propertie has_rights)
> can you give me some exemple.
> best regards

More information about the protege-owl mailing list