Search code examples
javaontologyowlprotegedlquery

DL Query and OWL


I have created an ontology in protege.

I have a class called AlcoholicBeverage, under this class there are subclasses Beer, Wine. These subclasses are disjoint.

I have a class called Person (no sub-classes). Another class called Behavior with two sub-classes "PositiveChange" and "NegativeChange".

I have an object property "using" with two sub-properties "drinking" and "consuming". Domain of "using" property is Person class and range is AlcoholicBeverage class.

NegativeChange class has superclass indicated with this statement "using some AlcoholicBeverage".

When I write DL query such as "using some Beer" or "drinking some Beer" or "consuming some Beer", it should classify it as NegativeChange but it does not. However, it only makes classification when I write "using some AlcoholicBeverage" which is exactly same definition written in AlcoholicBeverage superclass section. It does not take into account class or object inheritance. I expect that it should classify Beer as Alcoholic beverage or "consuming" object property as "using" object property.

Thanks for your help.


Solution

  • According to the query you formulate, it seems that you want to retrieve the persons that are using some alcohol.

    With your current constructs, the Behavior class is first "wrongly" classified as Person, because of the domain of the using object property. Moreover you should declare the anonymous expression using some AlcoholicBeverage as equivalent to the NegativeChange class and not as super class as it is currently the case. The queries using some Beer or drinking some Wine would then be correctly classified under NegativeChange.

    The semantically correct solution to retrieve the alcohol consumers would be to create a class called AlcoholConsumer, subclass of Person. The equivalent definition of AlcoholConsumer would be using some AlcoholicBeverage. Implementation using Brain:

    public static void main(String[] args) throws BrainException {
        //Declare all the axioms
        Brain brain = new Brain();
        brain.addClass("AlcoholicBeverage");
        brain.addClass("Beer");
        brain.subClassOf("Beer", "AlcoholicBeverage");
        brain.addClass("Wine");
        brain.subClassOf("Wine", "AlcoholicBeverage");
        brain.addClass("Person");
        brain.addObjectProperty("using");
        brain.addObjectProperty("drinking");
        brain.subPropertyOf("drinking", "using");
        brain.addObjectProperty("consuming");
        brain.subPropertyOf("consuming", "using");
    
        brain.addClass("AlcoholConsumer");
        brain.subClassOf("AlcoholConsumer", "Person");
        brain.equivalentClasses("AlcoholConsumer", "using some AlcoholicBeverage");
    
        //Add the queries
        brain.addClass("Query1");
        brain.equivalentClasses("Query1", "using some Beer");
    
        brain.addClass("Query2");
        brain.equivalentClasses("Query2", "drinking some Beer");
    
        brain.addClass("Query3");
        brain.equivalentClasses("Query3", "consuming some Wine");
    
        List<String> subClasses = brain.getSubClasses("AlcoholConsumer", false);
        //Should list all the queries
        System.out.println(subClasses);
    
       brain.sleep();
       brain.save("/home/samuel/Desktop/so.owl");
    }