@Override default Stream<?> components() { return Stream.of(getIndividual(), getClassExpression(), annotationsAsList()); }
@Override default Stream<?> componentsWithoutAnnotations() { return Stream.of(getIndividual(), getClassExpression()); }
@Override public void visit(OWLClassAssertionAxiom axiom) { if (!axiom.getClassExpression().isAnonymous()) { source = axiom.getIndividual().asOWLNamedIndividual(); target = axiom.getClassExpression().asOWLClass(); } }
@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; }
private NamedIndividualFrame translateToNamedIndividualFrame(OWLNamedIndividualData subject) { var relevantAxioms = getRelevantAxioms(subject.getEntity()); ImmutableSet<OWLClassData> types = relevantAxioms.stream() .filter(ax -> ax instanceof OWLClassAssertionAxiom) .map(ax -> (OWLClassAssertionAxiom) ax) .filter(ax -> !ax.getClassExpression().isAnonymous()) .map(ax -> ax.getClassExpression().asOWLClass()) .map(rm::getClassData) .sorted() propertyValues.addAll(translator.getPropertyValues(subject.getEntity(), axiom, rootOntology, State.ASSERTED)); for(OWLOntology ont : rootOntology.getImportsClosure()) { for(OWLClassAssertionAxiom ax : ont.getClassAssertionAxioms(subject.getEntity())) { if(!ax.getClassExpression().isAnonymous()) { var type = (OWLClass) ax.getClassExpression(); var classFrameTranslator = translatorProvider.get(); var classFrame = classFrameTranslator.getFrame(rm.getClassData(type)); propertyValuesMin.sort(propertyValueComparator); ImmutableSet<OWLNamedIndividualData> sameIndividuals = rootOntology.getImportsClosure().stream() .flatMap(ont -> ont.getSameIndividualAxioms(subject.getEntity()).stream()) .flatMap(ax -> ax.getIndividuals().stream())
ont.getClassAssertionAxioms(individual).stream() .filter(ax -> !ax.getClassExpression().isAnonymous()) .map(ax -> ax.getClassExpression().asOWLClass()) .sorted(c) .forEach(cls -> renderEntities(typesPage, Collections.singleton(cls))); .thenComparing(OWLAnnotationAssertionAxiom::getValue, valueComparator); ont.getAnnotationAssertionAxioms(individual).stream() .sorted(annotationAssertionAxiomComparator) .forEach(ax -> {
if (!isFiltered(AxiomType.CLASS_ASSERTION)) { SectionMap<Object, OWLAxiom> expressions = new SectionMap<>(); filtersort(o.classAssertionAxioms(individual)).forEach(ax -> { expressions.put(ax.getClassExpression(), ax); axioms.add(ax); }); .of(o.objectPropertyAssertionAxioms(individual), o .negativeObjectPropertyAssertionAxioms(individual), o.dataPropertyAssertionAxioms(individual), o .negativeDataPropertyAssertionAxioms(individual)).flatMap(x -> x).sorted(ooc) .collect(toList()); if (!assertions.isEmpty()) {
public MacroExpansions() { inputOntology.axioms(AxiomType.SUBCLASS_OF).forEach(axiom -> { OWLAxiom newAxiom = axiom.accept(visitor); replaceIfDifferent(axiom, newAxiom); }); inputOntology.axioms(AxiomType.EQUIVALENT_CLASSES).forEach(axiom -> { OWLAxiom newAxiom = axiom.accept(visitor); replaceIfDifferent(axiom, newAxiom); }); inputOntology.axioms(AxiomType.CLASS_ASSERTION).forEach(axiom -> { OWLAxiom newAxiom = axiom.accept(visitor); replaceIfDifferent(axiom, newAxiom); }); add(rmAxioms, inputOntology.axioms(AxiomType.ANNOTATION_ASSERTION).filter(this::expand)); }
private void createEdgesForPropertyAssertions(Set<Edge> edges, Set<OWLEntity> processed, OWLNamedIndividual individual, OWLNamedIndividualData individualData) { getOntologies() .flatMap(o -> o.getClassAssertionAxioms(individual).stream()) .filter(ax -> isNotOwlThing(ax.getClassExpression())) .filter(ax -> isNamedClass(ax.getClassExpression())) .forEach(ax -> { var cls = ax.getClassExpression().asOWLClass(); var clsData = renderer.getClassData(cls); edges.add(IsAEdge.get(individualData, clsData)); createEdgesForClass(edges, processed, cls); }); }
@Override public NodeSet<OWLClass> getTypes(OWLNamedIndividual ind, boolean direct) { ensurePrepared(); DefaultNodeSet<OWLClass> result = new OWLClassNodeSet(); getRootOntology().importsClosure().flatMap(o -> o.classAssertionAxioms(ind)) .forEach(ax -> addClasses(direct, result, ax.getClassExpression())); return result; }
public Entity entity(OWLNamedIndividual individual) { String id = namer.individualEntityName(individual.getIRI()); Entity entity = tx.getConcept(ConceptId.of(id)); if (entity != null) { return entity; } OWLClass owlclass = eval(() -> { Optional<OWLClassAssertionAxiom> expr = ontology .classAssertionAxioms(individual) .filter(ax -> ax.getClassExpression().isOWLClass()) .findFirst(); return expr.isPresent() ? expr.get().getClassExpression().asOWLClass() : null; }); return putEntity(id, owlclass == null ? owlThingEntityType() : entityType(owlclass)); }
public MacroExpansions() { visitor = new GCIVisitor(inputOntology, newAxioms); inputOntology.axioms(AxiomType.SUBCLASS_OF).forEach(axiom -> axiom.accept(visitor)); inputOntology.axioms(AxiomType.EQUIVALENT_CLASSES) .forEach(axiom -> axiom.accept(visitor)); inputOntology.axioms(AxiomType.CLASS_ASSERTION).forEach(axiom -> axiom.accept(visitor)); inputOntology.axioms(AxiomType.ANNOTATION_ASSERTION).forEach(this::expand); }
private static Map<OWLClass, Integer> countIndividuals(final OWLOntology ontology) { final Map<OWLClass, Integer> individualCount = new HashMap<>(); ontology.axioms(AxiomType.CLASS_ASSERTION).forEach(axiom -> { final OWLClassExpression desc = axiom.getClassExpression(); if (!desc.isAnonymous()) { final OWLClass assertedClass = desc.asOWLClass(); Integer oldCount = individualCount.get(assertedClass); if (oldCount == null) oldCount = 0; individualCount.put(assertedClass, oldCount + 1); } }); return individualCount; }
@Override public boolean isEntailed(@Nonnull OWLAxiom axiom) throws ReasonerInterruptedException, UnsupportedEntailmentTypeException, TimeOutException, AxiomNotInProfileException, FreshEntitiesException, InconsistentOntologyException { boolean containsAxiom = getRootOntology().containsAxiom(axiom, INCLUDED, AxiomAnnotations.IGNORE_AXIOM_ANNOTATIONS); ensurePrepared(); OWLClassExpression ce = ((OWLClassAssertionAxiom) axiom).getClassExpression(); OWLIndividual individual = ((OWLClassAssertionAxiom) axiom).getIndividual(); if (ce.isOWLThing()) { return true; } else if (ce.isOWLNothing()) { return false; } else if (!ce.isAnonymous()) { return getSubClasses(ce.asOWLClass(), false).getFlattened().stream() .anyMatch(sub -> getRootOntology().containsAxiom(df.getOWLClassAssertionAxiom(sub, individual), INCLUDED, AxiomAnnotations.IGNORE_AXIOM_ANNOTATIONS)); } else { if (ce instanceof OWLObjectIntersectionOf) { return ((OWLObjectIntersectionOf) ce).getOperands().stream() .allMatch(op -> isEntailed(df.getOWLClassAssertionAxiom(op, individual))); } else if (ce instanceof OWLObjectUnionOf) { return ((OWLObjectUnionOf) ce).getOperands().stream() .anyMatch(op -> isEntailed(df.getOWLClassAssertionAxiom(op, individual))); } else if (ce instanceof OWLObjectSomeValuesFrom) { OWLObjectPropertyExpression ope = ((OWLObjectSomeValuesFrom) ce).getProperty(); Set<OWLIndividualAxiom> axioms = getRootOntology().getAxioms(individual, INCLUDED);
@Override public OWLAxiom visit(OWLClassAssertionAxiom axiom) { if (axiom.getClassExpression().isAnonymous()) { return df.getOWLClassAssertionAxiom(axiom.getClassExpression().accept(classVisitor), axiom.getIndividual()); } return axiom; }
public Set<OWLObject> getParents(OWLObject object) { if (object instanceof OWLNamedIndividual) { OWLIndividual ind = (OWLNamedIndividual) object; Set<OWLObject> clses = new HashSet<>(); for (OWLOntology ont : ontologies) { for (OWLClassAssertionAxiom ax : ont.getClassAssertionAxioms(ind)) { if (!ax.getClassExpression().isAnonymous()) { clses.add(ax.getClassExpression().asOWLClass()); } } } return clses; } return Collections.emptySet(); }
@Override public OWLClassAssertionAxiom visit(OWLClassAssertionAxiom ax) { return df.getOWLClassAssertionAxiom(t(ax.getClassExpression()), t(ax.getIndividual()), a(ax)); }
@Override public Object visit(OWLClassAssertionAxiom axiom) { return visitAxiom(axiom, () -> df.getOWLClassAssertionAxiom(t(axiom.getClassExpression()), t(axiom .getIndividual()), t(axiom.annotations()))); }
@Override public void visit(OWLClassAssertionAxiom axiom) { OWLClassExpression sub = dataFactory.getOWLObjectOneOf(axiom.getIndividual()); OWLAxiom ax = dataFactory.getOWLSubClassOfAxiom(sub, axiom.getClassExpression()); ax.accept(this); }
/** * Builder initialized from an existing object. * * @param expected the existing object * @param df data factory */ public BuilderClassAssertion(OWLClassAssertionAxiom expected, OWLDataFactory df) { this(df); withClass(expected.getClassExpression()).withIndividual(expected.getIndividual()) .withAnnotations(expected.annotations()); }