根据您制定的查询,您似乎想要检索正在使用酒精的人。
使用您当前的构造,由于using对象属性的域,Behavior 类首先被“错误地”归类为 Person。此外,您应该使用一些 AlcoholicBeverage将匿名表达式声明为等效于 NegativeChange 类,而不是像现在这样的超类。使用一些啤酒或喝一些葡萄酒的查询将被正确分类在 NegativeChange 下。
检索酒精消费者的语义正确解决方案是创建一个名为 AlcoholConsumer 的类,它是 Person 的子类。酒精消费者的等效定义是使用一些酒精饮料。使用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");
}