public boolean contains(OWLClass cls) {
   if (cls.equals(owlOntologyManager.getOWLDataFactory().getOWLThing())) {
     return true;
   } else if (cls.equals(owlOntologyManager.getOWLDataFactory().getOWLNothing())) {
     return true;
   }
   return owlClass2ClassPointerMap.containsKey(cls);
 }
Esempio n. 2
0
 /**
  * filters the result of e.g. getSubclasses which is Set<Set<OWLClass>> To Set<OWLClass>
  *
  * @param original
  * @return
  * @throws OWLReasonerException
  */
 protected Set<OWLClass> filterClasses(Set<Set<OWLClass>> original) throws OWLReasonerException {
   Set<OWLClass> result = new HashSet<OWLClass>();
   for (Set<OWLClass> set : original) {
     for (Iterator<OWLClass> it = set.iterator(); it.hasNext(); ) {
       OWLClass cls = it.next();
       if (cls.getURI().equals(OWLRDFVocabulary.OWL_NOTHING)) {
         it.remove();
       } else {
         result.add(cls);
       }
     }
   }
   return result;
 }
 public void visit(OWLClass owlClass) {
   try {
     lastClassPointer = owlClass2ClassPointerMap.get(owlClass);
     // Cache if not in map
     if (lastClassPointer == null) {
       if (owlClass.getURI().equals(OWLRDFVocabulary.OWL_THING.getURI())) {
         lastClassPointer = faCTPlusPlus.getThing();
       } else if (owlClass.getURI().equals(OWLRDFVocabulary.OWL_NOTHING.getURI())) {
         lastClassPointer = faCTPlusPlus.getNothing();
       } else {
         lastClassPointer = faCTPlusPlus.getNamedClass(owlClass.getURI().toString());
       }
       classPointerMap.put(lastClassPointer, owlClass);
       owlClass2ClassPointerMap.put(owlClass, lastClassPointer);
     }
   } catch (Exception e) {
     throw new FaCTPlusPlusRuntimeException(e);
   }
 }
Esempio n. 4
0
  /**
   * Gets OWL class by given name
   *
   * @param className
   * @return
   * @throws OWLReasonerException
   */
  public OWLClass getNamedClass(String className) {

    if (classnameCache == null) {
      classnameCache = new HashMap<String, URI>();
      for (OWLOntology ont : reasoner.getLoadedOntologies()) {
        for (OWLClass cls : ont.getReferencedClasses()) {
          classnameCache.put(cls.toString(), cls.getURI());
        }
      }
    }

    OWLClass namedCls = null;
    URI uri = classnameCache.get(className);
    if (uri != null) {
      namedCls = manager.getOWLDataFactory().getOWLClass(uri);
    } else {
      System.err.println("Cannot find class: " + className + " in loaded ontologies");
    }

    return namedCls;
  }
Esempio n. 5
0
  /**
   * Gets the main temperature categories. This actually returns the direct named subclasses of the
   * Temperature class.
   *
   * @return A <code>Collection</code> of <code>OWLNamedClasses</code>
   */
  public Collection getTemperatureCategories() throws OWLReasonerException {

    OWLClass temperatureCls = this.getNamedClass(PREFERENCES.getTemperatureClassName());
    return temperatureCls.getSubClasses(ontology);
  }
Esempio n. 6
0
  /**
   * Gets the main base categories. This actually returns the direct named subclasses of the Bases
   * class.
   *
   * @return A <code>Collection</code> of <code>OWLNamedClasses</code>
   */
  public Collection getCoffeeBasesCategories() throws OWLReasonerException {

    OWLClass basesCls = this.getNamedClass(PREFERENCES.getBaseClassName());
    return basesCls.getSubClasses(ontology);
  }