Thank you Dave, I've exactly see what I missed.
... 2013/7/9 Dave Reynolds <[email protected]> > On 09/07/13 05:12, Erdem Eser Ekinci wrote: > >> 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? >> > > That OWL with the standard open world semantics is fundamentally unsuited > to validation :) > > It is possible to use OWL syntax to express constraints but interpret it > with closed world semantics. See upcoming W3C workshop on this topic. But > the current jena rule reasoners follow the official semantics. > > In your example then a cardinality restriction on Role just means that > each Role instance can be deduced to have a hasGoal, and indeed the > reasoner will invent an existential variable (blank node) to represent the > missing value. > > Similarly a someValues restriction just means that the reasoner can deduce > there is a hasGoal value and that it must be a Goal. > > An allValues restriction allows you to deduce that all your hasGoal values > must be Goals but tells you nothing about missing goals. If you made the > value of a hasGoal instance a Task, and if you declare Task and Goal to be > disjoint then your allValues (or a simple range declaration) would allow > you to detect a problem. > > Dave > > > >> Thanks for your help... >> >> public class OWLRestrictionTest { >> //uri defs >> private static String URI_BASE = " >> http://www.galaksiya.com/**ontologies/galaxia.owl<http://www.galaksiya.com/ontologies/galaxia.owl> >> "; >> private static String URI_INDV = " >> http://www.galaksiya.com/**ontologies/indv.owl<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.**createSomeValuesFromRestrictio** >> n(null, >> prpHasGoal, clssGoal); >> Restriction restriction = >> schema.**createAllValuesFromRestriction**(null, prpHasGoal, clssGoal); >> //Restriction restriction = schema.**createMinCardinalityRestrictio** >> n(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İ
