private void initialiseReasoner() throws OWLException { /* Initialise the kb and make sure that top and bottom are in there. */ tell("<clearKB/>"); tell("<defconcept name=\"" + OWLVocabularyAdapter.INSTANCE.getThing() + "\"/>"); tell( "<equalc><catom name=\"" + OWLVocabularyAdapter.INSTANCE.getThing() + "\"/><top/></equalc>"); tell("<defconcept name=\"" + OWLVocabularyAdapter.INSTANCE.getNothing() + "\"/>"); tell( "<equalc><catom name=\"" + OWLVocabularyAdapter.INSTANCE.getNothing() + "\"/><bottom/></equalc>"); }
private void checkCorrectOWLNamespaceUsage() throws OWLException { /* Check that nothing's been defined in the OWL namespace. */ try { for (Iterator it = allURIs.iterator(); it.hasNext(); ) { URI uri = (URI) it.next(); if (uri != null) { String str = uri.toString(); if (str.startsWith(OWLVocabularyAdapter.OWL) && !str.equals(OWLVocabularyAdapter.INSTANCE.getThing()) && !str.equals(OWLVocabularyAdapter.INSTANCE.getNothing()) && /* Added check for built ins */ !OWLVocabularyAdapter.INSTANCE.getAnnotationProperties().contains(str)) { correctOWLNamespaceUsage = false; explain( FULL, OWLNAMESPACEUSED, encodeHLink(str, myModel.shortForm(uri)) + " in OWL Namespace"); } } } } catch (Exception ex) { ex.printStackTrace(); throw new OWLException(ex.getMessage()); } }
private OWLClass conceptToClass(uk.ac.man.cs.img.dig.helper.Response.Concept c) throws OWLException { try { if (c.isBottom()) { OWLClass clazz = ontology.getClass(new URI(OWLVocabularyAdapter.INSTANCE.getNothing())); // System.out.println( clazz ); return clazz; } else if (c.isTop()) { return ontology.getClass(new URI(OWLVocabularyAdapter.INSTANCE.getThing())); } else { uk.ac.man.cs.img.dig.helper.Response.ConceptName cn = (uk.ac.man.cs.img.dig.helper.Response.ConceptName) c; // System.out.println( "xx " + cn.toString() ); URI classURI = new URI(cn.toString()); /* This is wrong! The problem is that the URI may not * be of a class *in* this ontology (due to the way * that we handle imports). So rather than getting the * class from the ontology, we need to get the class * from the data factory. */ // OWLClass clazz = ontology.getClass( classURI ); OWLClass clazz = ontology.getOWLDataFactory().getOWLClass(classURI); // System.out.println( clazz ); return clazz; } } catch (URISyntaxException ex) { throw new OWLException(ex.getMessage()); } }
private void checkCorrectOWLUsage() throws OWLException { /* Check that nothing in the OWL vocabulary has been redefined. */ /* * This was too strong. We are actually allowed to say that some things * e.g. Bag, Set, Alt and Statement are classes. Also some other stuff * in the RDF vocabulary. SKB. */ try { for (Iterator it = classURIs.iterator(); it.hasNext(); ) { URI uri = (URI) it.next(); if (uri != null && reservedVocabulary.contains(uri.toString())) { if (!classOnlyVocabulary.contains(uri.toString())) { /* * It's a redefinition of something that we can't * redefine. */ correctOWLUsage = false; explain( FULL, BUILTINREDEFINITION, "Redefinition of: " + encodeHLink(uri.toString(), myModel.shortForm(uri))); } } } for (Iterator it = individualURIs.iterator(); it.hasNext(); ) { URI uri = (URI) it.next(); if (uri != null && reservedVocabulary.contains(uri.toString())) { /* It's a redefinition of something that we can't redefine. */ correctOWLUsage = false; explain( FULL, BUILTINREDEFINITION, "Redefinition of: " + encodeHLink(uri.toString(), myModel.shortForm(uri))); } } for (Iterator it = objectPropertyURIs.iterator(); it.hasNext(); ) { URI uri = (URI) it.next(); if (uri != null && reservedVocabulary.contains(uri.toString())) { /* It's a redefinition of something that we can't redefine. */ correctOWLUsage = false; explain( FULL, BUILTINREDEFINITION, "Redefinition of: " + encodeHLink(uri.toString(), myModel.shortForm(uri))); } } for (Iterator it = dataPropertyURIs.iterator(); it.hasNext(); ) { URI uri = (URI) it.next(); if (uri != null && reservedVocabulary.contains(uri.toString())) { /* It's a redefinition of something that we can't redefine. */ correctOWLUsage = false; explain( FULL, BUILTINREDEFINITION, "Redefinition of: " + encodeHLink(uri.toString(), myModel.shortForm(uri))); } } for (Iterator it = datatypeURIs.iterator(); it.hasNext(); ) { URI uri = (URI) it.next(); if (uri != null && reservedVocabulary.contains(uri.toString()) || /* * Nasty. Need to check that thing/nothing aren't * redefined as datatypes. */ uri.toString().equals(OWLVocabularyAdapter.INSTANCE.getThing()) || uri.toString().equals(OWLVocabularyAdapter.INSTANCE.getNothing())) { /* It's a redefinition of something that we can't redefine. */ correctOWLUsage = false; explain( FULL, BUILTINREDEFINITION, "Redefinition of: " + encodeHLink(uri.toString(), myModel.shortForm(uri))); } } } catch (Exception ex) { ex.printStackTrace(); throw new OWLException(ex.getMessage()); } }