Hi all,

I need some help to validate an ontology. The code is as follows. The
ontology is simple; there are tree concepts; Role, Goal, Task and one
object property hasGoal whose domain is Role and range is Goal. I've tried
to restrict Role concept on the hasGoal property with allvalues, somevalues
and mincardinality restrictions separately. But none of them hampers the
validity. Always validation true.

What am I missing?

Thanks for your help...

public class OWLRestrictionTest {
        //uri defs
 private static String URI_BASE = "
http://www.galaksiya.com/ontologies/galaxia.owl";;
private static String URI_INDV = "
http://www.galaksiya.com/ontologies/indv.owl";;
 private static String URI_ROLE = "Role";
private static String URI_GOAL = "Goal";
 private static String URI_TASK = "Task";
private static String URI_HAS_GOAL = "hasGoal";

// concepts
private OntClass clssRole;
private OntClass clssGoal;
 private OntClass clssTask;
 private ObjectProperty prpHasGoal;
 @Test
public void test() {
OntModel schema =
ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);
 //create concepts
clssRole = schema.createClass(URI_BASE + "#" + URI_ROLE);
clssGoal = schema.createClass(URI_BASE + "#" + URI_GOAL);
 clssTask = schema.createClass(URI_BASE + "#" + URI_TASK);
//create properties
prpHasGoal = schema.createObjectProperty(URI_BASE + "#" + URI_HAS_GOAL);
 //create restrictions
//Restriction restriction = schema.createSomeValuesFromRestriction(null,
prpHasGoal, clssGoal);
                Restriction restriction =
schema.createAllValuesFromRestriction(null, prpHasGoal, clssGoal);
//Restriction restriction = schema.createMinCardinalityRestriction(null,
prpHasGoal, 2);
 clssRole.addSuperClass(restriction);
 OntModel data = ModelFactory.createOntologyModel();
 //create individuals
Individual indvRole1 = data.createIndividual(URI_INDV+"#FetcherRole1",
clssRole);
 Individual indvGoal1 = data.createIndividual(URI_INDV+"#FetchGoal1",
clssGoal);
Individual indvTask1 = data.createIndividual(URI_INDV+"#FetchTask1",
clssTask);
 //indvRole1.addProperty(prpHasGoal, indvGoal1);
indvRole1.addProperty(prpHasGoal, indvTask1);
 //validation
schema.write(System.out,"N3");
 ValidityReport validityReport = schema.validate();
if(validityReport != null)
 System.out.println("Model consistency: " + validityReport.isValid());
else
System.out.println("No consistency report");
 Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
reasoner.bindSchema(schema);
 InfModel infModel = ModelFactory.createInfModel(reasoner, data);
infModel.write(System.out,"N3");
 ValidityReport validityReport1 = infModel.validate();
if(validityReport1 != null)
System.out.println("Model consistency: " + validityReport1.isValid());
 else
System.out.println("No consistency report");
}

-- 
Galaksiya Bilişim Teknolojileri
Erdem Eser EKİNCİ

Reply via email to