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());
   }
 }
示例#2
0
 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());
   }
 }
示例#3
0
 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>");
 }
  /** Create a new validator. Will report to stdout by default. */
  public SwoopSpeciesValidator(SwoopModel model) throws OWLException {
    myModel = model;
    /* Sets up a default reporter that writes to stdout. */
    setReporter(
        new SpeciesValidatorReporter() {
          public void ontology(OWLOntology onto) {
            // System.out.println( onto.getURI() );
          }

          public void done(String str) {
            // System.out.println( str );
          }

          public void message(String str) {
            System.out.println(str);
          }

          public void explain(int l, int code, String str) {
            System.out.println(level(l) + " [" + readableCode(code) + "]:\t" + str);
            // System.out.println( level( l ) + ":\t" + str );
          }
        });
    reservedVocabulary = OWLVocabularyAdapter.INSTANCE.getReservedVocabulary();

    classOnlyVocabulary = new HashSet();
    classOnlyVocabulary.add(OWLVocabularyAdapter.INSTANCE.getStatement());
    classOnlyVocabulary.add(OWLVocabularyAdapter.INSTANCE.getSeq());
    classOnlyVocabulary.add(OWLVocabularyAdapter.INSTANCE.getBag());
    classOnlyVocabulary.add(OWLVocabularyAdapter.INSTANCE.getAlt());

    options = new HashMap();

    /* Get a default connection */
    connection = OWLManager.getOWLConnection();

    parser = new OWLRDFParser();
    /*
     * Tell the parser to ignore annotation content. This is not needed for
     * validation.
     */
    Map options = new HashMap();
    options.put("includeAnnotationContent", new Boolean(false));
    parser.setOptions(options);
  }
 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());
   }
 }