@Override public OWLReasoner createNonBufferingReasoner(OWLOntology ontology, OWLReasonerConfiguration config) { return new StructuralReasoner(ontology, config, BufferingMode.NON_BUFFERING); }
private void dumpClassHierarchy(Node<OWLClass> cls, int level, boolean showBottomNode) { if (!showBottomNode && cls.isBottomNode()) { return; } printIndent(level); OWLClass representative = cls.getRepresentativeElement(); System.out.println(getEquivalentClasses(representative)); for (Node<OWLClass> subCls : getSubClasses(representative, true)) { dumpClassHierarchy(subCls, level + 1, showBottomNode); } }
private void dumpDataPropertyHierarchy(Node<OWLDataProperty> cls, int level, boolean showBottomNode) { if (!showBottomNode && cls.isBottomNode()) { return; } printIndent(level); OWLDataProperty representative = cls.getRepresentativeElement(); System.out.println(getEquivalentDataProperties(representative)); for (Node<OWLDataProperty> subProp : getSubDataProperties(representative, true)) { dumpDataPropertyHierarchy(subProp, level + 1, showBottomNode); } }
private void dumpObjectPropertyHierarchy(Node<OWLObjectPropertyExpression> cls, int level, boolean showBottomNode) { if (!showBottomNode && cls.isBottomNode()) { return; } printIndent(level); OWLObjectPropertyExpression representative = cls.getRepresentativeElement(); System.out.println(getEquivalentObjectProperties(representative)); for (Node<OWLObjectPropertyExpression> subProp : getSubObjectProperties(representative, true)) { dumpObjectPropertyHierarchy(subProp, level + 1, showBottomNode); } }
@Override public NodeSet<OWLClass> getObjectPropertyRanges(OWLObjectPropertyExpression pe, boolean direct) { ensurePrepared(); DefaultNodeSet<OWLClass> result = new OWLClassNodeSet(); getRootOntology().importsClosure().forEach(ontology -> { ontology.objectPropertyRangeAxioms(pe).forEach(axiom -> { result.addNode(getEquivalentClasses(axiom.getRange())); if (!direct) { result.addAllNodes(getSuperClasses(axiom.getRange(), false).nodes()); } }); getInverseObjectProperties(pe).entities().flatMap(ontology::objectPropertyDomainAxioms) .forEach(axiom -> { result.addNode(getEquivalentClasses(axiom.getDomain())); if (!direct) { result.addAllNodes(getSuperClasses(axiom.getDomain(), false).nodes()); } }); }); return result; }
@Override public NodeSet<OWLNamedIndividual> getObjectPropertyValues(OWLNamedIndividual ind, OWLObjectPropertyExpression pe) { ensurePrepared(); OWLNamedIndividualNodeSet result = new OWLNamedIndividualNodeSet(); Node<OWLObjectPropertyExpression> inverses = getInverseObjectProperties(pe); getRootOntology().importsClosure().flatMap(o -> o.objectPropertyAssertionAxioms(ind)) .forEach(axiom -> { if (!axiom.getObject().isAnonymous() && axiom.getProperty().getSimplified() .equals(pe.getSimplified())) { if (getIndividualNodeSetPolicy().equals(IndividualNodeSetPolicy.BY_SAME_AS)) { result .addNode(getSameIndividuals(axiom.getObject().asOWLNamedIndividual())); } else { result.addNode( .getSimplified(); if (!invPe.isAnonymous() && inverses.contains(invPe.asOWLObjectProperty())) { if (getIndividualNodeSetPolicy() .equals(IndividualNodeSetPolicy.BY_SAME_AS)) { result.addNode( getSameIndividuals(axiom.getObject().asOWLNamedIndividual())); } else { result.addNode(new OWLNamedIndividualNode(
@Override public NodeSet<OWLNamedIndividual> getInstances(OWLClassExpression ce, boolean direct) { ensurePrepared(); DefaultNodeSet<OWLNamedIndividual> result = new OWLNamedIndividualNodeSet(); if (ce.isAnonymous()) { return result; } OWLClass cls = ce.asOWLClass(); Set<OWLClass> clses = new HashSet<>(); clses.add(cls); if (!direct) { clses.addAll(asList(getSubClasses(cls, false).entities())); } for (OWLClass curCls : clses) { getRootOntology().importsClosure().flatMap(o -> o.classAssertionAxioms(curCls)) .map(ax -> ax .getIndividual()).filter(i -> !i.isAnonymous()) .map(i -> i.asOWLNamedIndividual()).forEach(i -> { if (getIndividualNodeSetPolicy().equals(IndividualNodeSetPolicy.BY_SAME_AS)) { result.addNode(getSameIndividuals(i)); } else { result.addNode(new OWLNamedIndividualNode(i)); } }); } return result; }
@Override public Set<OWLLiteral> getDataPropertyValues(OWLNamedIndividual ind, OWLDataProperty pe) { ensurePrepared(); Set<OWLLiteral> literals = new HashSet<>(); Set<OWLDataProperty> superProperties = asUnorderedSet( Stream.concat(getSuperDataProperties(pe, false) .entities(), getEquivalentDataProperties(pe).entities())); getRootOntology().importsClosure().flatMap(o -> o.dataPropertyAssertionAxioms(ind)) .forEach(ax -> { if (superProperties.contains(ax.getProperty().asOWLDataProperty())) { literals.add(ax.getObject()); } }); return literals; }
@Override public NodeSet<OWLDataProperty> getDisjointDataProperties(OWLDataPropertyExpression pe) { ensurePrepared(); DefaultNodeSet<OWLDataProperty> result = new OWLDataPropertyNodeSet(); getRootOntology().importsClosure() .flatMap(o -> o.disjointDataPropertiesAxioms(pe.asOWLDataProperty())).forEach( axiom -> { for (OWLDataPropertyExpression dpe : axiom.getPropertiesMinus(pe)) { if (!dpe.isAnonymous()) { result.addNode( dataPropertyHierarchyInfo.getEquivalents(dpe.asOWLDataProperty())); result.addAllNodes( getSubDataProperties(dpe.asOWLDataProperty(), false).nodes()); } } }); return result; }
public NodeSet<OWLNamedIndividual> getInstances(OWLClassExpression ce, boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { DefaultNodeSet<OWLNamedIndividual> result = new OWLNamedIndividualNodeSet(); if (!ce.isAnonymous()) { OWLClass cls = ce.asOWLClass(); for (OWLOntology ontology : getRootOntology().getImportsClosure()) { for (OWLClassAssertionAxiom axiom : ontology.getClassAssertionAxioms(cls)) { OWLIndividual individual = axiom.getIndividual(); if (!individual.isAnonymous()) { if (getIndividualNodeSetPolicy().equals(IndividualNodeSetPolicy.BY_SAME_AS)) { result.addNode(getSameIndividuals(individual.asOWLNamedIndividual())); } else { result.addNode(new OWLNamedIndividualNode(individual.asOWLNamedIndividual())); } if (!direct) { for (Node<OWLClass> node : getSubClasses(ce, false)) { for (OWLClass c : node.getEntities()) { result.addAllNodes(getInstances(c, true).getNodes()); } } } } } } } return result; }
protected void addClasses(boolean direct, DefaultNodeSet<OWLClass> result, OWLClassExpression domain) { result.addNode(getEquivalentClasses(domain)); if (!direct) { result.addAllNodes(getSuperClasses(domain, false).nodes()); } }
@Override public Node<OWLObjectPropertyExpression> getInverseObjectProperties( OWLObjectPropertyExpression pe) { ensurePrepared(); OWLObjectPropertyExpression inv = pe.getInverseProperty().getSimplified(); return getEquivalentObjectProperties(inv); }
public NodeSet<OWLClass> getDataPropertyDomains(OWLDataProperty pe, boolean direct) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { DefaultNodeSet<OWLClass> result = new OWLClassNodeSet(); for (OWLOntology ontology : getRootOntology().getImportsClosure()) { for (OWLDataPropertyDomainAxiom axiom : ontology.getDataPropertyDomainAxioms(pe)) { result.addNode(getEquivalentClasses(axiom.getDomain())); if (!direct) { result.addAllNodes(getSuperClasses(axiom.getDomain(), false).getNodes()); } } } return result; }
Set<OWLDataProperty> superProperties = getSuperDataProperties(pe, false).getFlattened(); superProperties.addAll(getEquivalentDataProperties(pe).getEntities()); for (OWLOntology ontology : getRootOntology().getImportsClosure()) { for (OWLDataPropertyAssertionAxiom axiom : ontology.getDataPropertyAssertionAxioms(ind)) { if (superProperties.contains(axiom.getProperty().asOWLDataProperty())) {
@Override public boolean isSatisfiable(OWLClassExpression classExpression) { return !classExpression.isAnonymous() && !getEquivalentClasses(classExpression.asOWLClass()) .contains( getDataFactory().getOWLNothing()); }
public Node<OWLObjectProperty> getInverseObjectProperties(OWLObjectPropertyExpression pe) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { Set<OWLObjectProperty> props = new HashSet<OWLObjectProperty>(); Set<OWLObjectProperty> equivalentObjectProperties = getEquivalentObjectProperties(pe).getEntities(); for (OWLObjectProperty property : equivalentObjectProperties) { for (OWLOntology ontology : getRootOntology().getImportsClosure()) { for (OWLInverseObjectPropertiesAxiom axiom : ontology.getInverseObjectPropertyAxioms(property)) { for (OWLObjectPropertyExpression invProp : axiom.getPropertiesMinus(property)) { OWLObjectPropertyExpression invPropSimp = invProp.getSimplified(); if (!invProp.isAnonymous()) { props.add(invPropSimp.asOWLObjectProperty()); props.addAll(getEquivalentObjectProperties(invPropSimp).getEntities()); } } } } } return new OWLObjectPropertyNode(props); }
public NodeSet<OWLDataProperty> getDisjointDataProperties(OWLDataPropertyExpression pe, boolean direct) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { DefaultNodeSet<OWLDataProperty> result = new OWLDataPropertyNodeSet(); for (OWLOntology ontology : getRootOntology().getImportsClosure()) { for (OWLDisjointDataPropertiesAxiom axiom : ontology.getDisjointDataPropertiesAxioms(pe.asOWLDataProperty())) { for (OWLDataPropertyExpression dpe : axiom.getPropertiesMinus(pe)) { if (!dpe.isAnonymous()) { result.addNode(dataPropertyHierarchyInfo.getEquivalents(dpe.asOWLDataProperty())); if (!direct) { result.addAllNodes(getSubDataProperties(dpe.asOWLDataProperty(), false).getNodes()); } } } } } return result; }
@Nonnull @Override public Node<OWLDataProperty> getEquivalentDataProperties(@Nonnull OWLDataProperty pe) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { return structuralReasoner.getEquivalentDataProperties(pe); }
@Nonnull @Override public Node<OWLObjectPropertyExpression> getInverseObjectProperties(@Nonnull OWLObjectPropertyExpression pe) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { return structuralReasoner.getInverseObjectProperties(pe); }
@Nonnull @Override public NodeSet<OWLObjectPropertyExpression> getSubObjectProperties(@Nonnull OWLObjectPropertyExpression pe, boolean direct) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { return structuralReasoner.getSubObjectProperties(pe, direct); }