/** {@inheritDoc} */
 public boolean isPrecomputed(InferenceType inferenceType) {
   switch (inferenceType) {
     case CLASS_HIERARCHY:
       return kb.isClassified();
     case CLASS_ASSERTIONS:
       return kb.isRealized();
     case OBJECT_PROPERTY_HIERARCHY:
       return kb.getRBox().isObjectTaxonomyPrepared();
     case DATA_PROPERTY_HIERARCHY:
       return kb.getRBox().isDataTaxonomyPrepared();
     default:
       return false;
   }
 }
  /**
   * Create a reasoner for the given ontology and configuration.
   *
   * @param ontology
   */
  public PelletReasoner(
      OWLOntology ontology, OWLReasonerConfiguration config, BufferingMode bufferingMode)
      throws IllegalConfigurationException {

    individualNodeSetPolicy = config.getIndividualNodeSetPolicy();

    if (!getFreshEntityPolicy().equals(config.getFreshEntityPolicy())) {
      throw new IllegalConfigurationException(
          "PelletOptions.SILENT_UNDEFINED_ENTITY_HANDLING conflicts with reasoner configuration",
          config);
    }

    this.ontology = ontology;
    monitor = config.getProgressMonitor();

    kb = new KnowledgeBase();
    kb.setTaxonomyBuilderProgressMonitor(new ProgressAdapter(monitor));
    if (config.getTimeOut() > 0) {
      kb.timers.mainTimer.setTimeout(config.getTimeOut());
    }

    this.manager = ontology.getOWLOntologyManager();
    this.factory = manager.getOWLDataFactory();
    this.visitor = new PelletVisitor(kb);

    this.bufferingMode = bufferingMode;

    manager.addOntologyChangeListener(this);

    this.shouldRefresh = true;
    this.pendingChanges = new ArrayList<OWLOntologyChange>();

    refresh();
  }
 public boolean isConsistent() throws ReasonerInterruptedException, TimeOutException {
   refreshCheck();
   try {
     return kb.isConsistent();
   } catch (PelletRuntimeException e) {
     throw convert(e);
   }
 }
 /** {@inheritDoc} */
 public void precomputeInferences(InferenceType... inferenceTypes)
     throws ReasonerInterruptedException, TimeOutException, InconsistentOntologyException {
   for (InferenceType inferenceType : inferenceTypes) {
     switch (inferenceType) {
       case CLASS_HIERARCHY:
         kb.classify();
       case CLASS_ASSERTIONS:
         kb.realize();
       case OBJECT_PROPERTY_HIERARCHY:
         kb.getRBox().getObjectTaxonomy();
       case DATA_PROPERTY_HIERARCHY:
         kb.getRBox().getDataTaxonomy();
       default:
         break;
     }
   }
 }
 public Node<OWLClass> getUnsatisfiableClasses()
     throws ReasonerInterruptedException, TimeOutException {
   refreshCheck();
   try {
     return toClassNode(kb.getAllUnsatisfiableClasses());
   } catch (PelletRuntimeException e) {
     throw convert(e);
   }
 }
 public NodeSet<OWLNamedIndividual> getInstances(OWLClassExpression ce, boolean direct)
     throws InconsistentOntologyException, ClassExpressionNotInProfileException,
         FreshEntitiesException, ReasonerInterruptedException, TimeOutException {
   refreshCheck();
   try {
     return getIndividualNodeSet(kb.getInstances(term(ce), direct));
   } catch (PelletRuntimeException e) {
     throw convert(e);
   }
 }
 public Node<OWLNamedIndividual> getSameIndividuals(OWLNamedIndividual ind)
     throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException,
         TimeOutException {
   refreshCheck();
   try {
     return toIndividualNode(kb.getAllSames(term(ind)));
   } catch (PelletRuntimeException e) {
     throw convert(e);
   }
 }
 public Node<OWLDataProperty> getEquivalentDataProperties(OWLDataProperty pe)
     throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException,
         TimeOutException {
   refreshCheck();
   try {
     return toDataPropertyNode(kb.getAllEquivalentProperties(term(pe)));
   } catch (PelletRuntimeException e) {
     throw convert(e);
   }
 }
 public Node<OWLClass> getEquivalentClasses(OWLClassExpression ce)
     throws InconsistentOntologyException, ClassExpressionNotInProfileException,
         FreshEntitiesException, ReasonerInterruptedException, TimeOutException {
   refreshCheck();
   try {
     return toClassNode(kb.getAllEquivalentClasses(term(ce)));
   } catch (PelletRuntimeException e) {
     throw convert(e);
   }
 }
Beispiel #10
0
 public boolean isSatisfiable(OWLClassExpression classExpression)
     throws ReasonerInterruptedException, TimeOutException, ClassExpressionNotInProfileException,
         FreshEntitiesException, InconsistentOntologyException {
   refreshCheck();
   try {
     return kb.isSatisfiable(term(classExpression));
   } catch (PelletRuntimeException e) {
     throw convert(e);
   }
 }
Beispiel #11
0
 public Set<OWLLiteral> getDataPropertyValues(OWLNamedIndividual ind, OWLDataProperty pe)
     throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException,
         TimeOutException {
   refreshCheck();
   try {
     return toLiteralSet(kb.getDataPropertyValues(term(pe), term(ind)));
   } catch (PelletRuntimeException e) {
     throw convert(e);
   }
 }
Beispiel #12
0
 public Node<OWLObjectPropertyExpression> getInverseObjectProperties(
     OWLObjectPropertyExpression pe)
     throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException,
         TimeOutException {
   refreshCheck();
   try {
     return toObjectPropertyNode(kb.getInverses(term(pe)));
   } catch (PelletRuntimeException e) {
     throw convert(e);
   }
 }
Beispiel #13
0
 public NodeSet<OWLNamedIndividual> getObjectPropertyValues(
     OWLNamedIndividual ind, OWLObjectPropertyExpression pe)
     throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException,
         TimeOutException {
   refreshCheck();
   try {
     return getIndividualNodeSet(kb.getObjectPropertyValues(term(pe), term(ind)));
   } catch (PelletRuntimeException e) {
     throw convert(e);
   }
 }
Beispiel #14
0
 public NodeSet<OWLClass> getTypes(OWLNamedIndividual ind, boolean direct)
     throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException,
         TimeOutException {
   refreshCheck();
   try {
     Set<Set<ATermAppl>> result = kb.getTypes(term(ind), direct);
     return toClassNodeSet(result);
   } catch (PelletRuntimeException e) {
     throw convert(e);
   }
 }
Beispiel #15
0
 public NodeSet<OWLClass> getSuperClasses(OWLClassExpression ce, boolean direct)
     throws InconsistentOntologyException, ClassExpressionNotInProfileException,
         FreshEntitiesException, ReasonerInterruptedException, TimeOutException {
   refreshCheck();
   try {
     Set<Set<ATermAppl>> result = kb.getSuperClasses(term(ce), direct);
     return toClassNodeSet(result);
   } catch (PelletRuntimeException e) {
     throw convert(e);
   }
 }
Beispiel #16
0
  public NodeSet<OWLClass> getDisjointClasses(OWLClassExpression ce)
      throws InconsistentOntologyException, ClassExpressionNotInProfileException,
          FreshEntitiesException, ReasonerInterruptedException, TimeOutException {

    refreshCheck();
    try {
      Set<Set<ATermAppl>> disjoints = kb.getDisjointClasses(term(ce));
      return toClassNodeSet(disjoints);
    } catch (PelletRuntimeException e) {
      throw convert(e);
    }
  }
Beispiel #17
0
  private NodeSet<OWLNamedIndividual> getIndividualNodeSetByName(
      Collection<ATermAppl> individuals) {
    Set<Node<OWLNamedIndividual>> instances = new HashSet<Node<OWLNamedIndividual>>();

    for (ATermAppl ind : individuals) {
      for (ATermAppl equiv : kb.getAllSames(ind)) {
        instances.add(toIndividualNode(equiv));
      }
    }

    return new OWLNamedIndividualNodeSet(instances);
  }
Beispiel #18
0
  public NodeSet<OWLClass> getObjectPropertyRanges(OWLObjectPropertyExpression pe, boolean direct)
      throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException,
          TimeOutException {
    refreshCheck();
    try {
      ATermAppl some = ATermUtils.makeSomeValues(ATermUtils.makeInv(term(pe)), ATermUtils.TOP);

      Set<ATermAppl> equivalents = kb.getEquivalentClasses(some);
      if (direct && !equivalents.isEmpty()) {
        return toClassNodeSet(Collections.singleton(equivalents));
      }

      Set<Set<ATermAppl>> result = kb.getSuperClasses(some, direct);
      if (!equivalents.isEmpty()) {
        result.add(equivalents);
      }

      return toClassNodeSet(result);
    } catch (PelletRuntimeException e) {
      throw convert(e);
    }
  }
Beispiel #19
0
  /** Clears the reasoner and reloads all the axioms in the imports closure. */
  public void refresh() {
    visitor.clear();
    kb.clear();

    importsClosure = ontology.getImportsClosure();

    visitor.setAddAxiom(true);
    for (OWLOntology ont : importsClosure) {
      ont.accept(visitor);
    }
    visitor.verify();

    shouldRefresh = false;
  }
Beispiel #20
0
  private NodeSet<OWLNamedIndividual> getIndividualNodeSetBySameAs(
      Collection<ATermAppl> individuals) {
    Set<Node<OWLNamedIndividual>> instances = new HashSet<Node<OWLNamedIndividual>>();
    Set<ATermAppl> seen = new HashSet<ATermAppl>();
    for (ATermAppl ind : individuals) {
      if (!seen.contains(ind)) {
        Set<ATermAppl> equiv = kb.getAllSames(ind);
        instances.add(toIndividualNode(equiv));
        seen.addAll(equiv);
      }
    }

    return new OWLNamedIndividualNodeSet(instances);
  }
Beispiel #21
0
 public NodeSet<OWLDataProperty> getSuperDataProperties(OWLDataProperty pe, boolean direct)
     throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException,
         TimeOutException {
   refreshCheck();
   try {
     Set<Node<OWLDataProperty>> values = new HashSet<Node<OWLDataProperty>>();
     for (Set<ATermAppl> val : kb.getSuperProperties(term(pe), direct)) {
       values.add(toDataPropertyNode(val));
     }
     return new OWLDataPropertyNodeSet(values);
   } catch (PelletRuntimeException e) {
     throw convert(e);
   }
 }
Beispiel #22
0
  public NodeSet<OWLObjectPropertyExpression> getDisjointObjectProperties(
      OWLObjectPropertyExpression pe)
      throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException,
          TimeOutException {
    refreshCheck();
    try {
      Set<Node<OWLObjectPropertyExpression>> values =
          new HashSet<Node<OWLObjectPropertyExpression>>();
      for (Set<ATermAppl> val : kb.getDisjointProperties(term(pe))) {
        values.add(toObjectPropertyNode(val));
      }

      return new OWLObjectPropertyNodeSet(values);
    } catch (PelletRuntimeException e) {
      throw convert(e);
    }
  }
Beispiel #23
0
 /** {@inheritDoc} */
 public void prepareReasoner() throws ReasonerInterruptedException, TimeOutException {
   refreshCheck();
   if (kb.isConsistent()) {
     kb.realize();
   }
 }
Beispiel #24
0
 public Node<OWLObjectPropertyExpression> getTopObjectPropertyNode() {
   refreshCheck();
   return toObjectPropertyNode(kb.getAllEquivalentProperties(ATermUtils.TOP_OBJECT_PROPERTY));
 }
Beispiel #25
0
 public Node<OWLDataProperty> getTopDataPropertyNode() {
   refreshCheck();
   return toDataPropertyNode(kb.getAllEquivalentProperties(ATermUtils.TOP_DATA_PROPERTY));
 }
Beispiel #26
0
 public Node<OWLClass> getTopClassNode() {
   refreshCheck();
   return toClassNode(kb.getAllEquivalentClasses(ATermUtils.TOP));
 }