@Override default ChangeApplied addAxioms(OWLAxiom... axioms) { return addAxioms(Arrays.asList(axioms)); }
@Override default ChangeApplied addAxioms(OWLAxiom... axioms) { return addAxioms(Arrays.asList(axioms)); }
@Override default ChangeApplied addAxioms(OWLAxiom... axioms) { return addAxioms(Arrays.asList(axioms)); }
/** * @param axioms to change * @return true changes list * @since 2.5.1 */ default public ChangeApplied addAxioms(final Stream<OWLAxiom> axioms) { return getOntology().addAxioms(axioms); }
/** * @param axioms to change * @return true changes list * @since 2.5.1 */ default public ChangeApplied addAxioms(final Stream<OWLAxiom> axioms) { return getOntology().addAxioms(axioms); }
/** * @param axioms to change * @return true changes list * @since 2.5.1 */ default public ChangeApplied addAxioms(final Stream<OWLAxiom> axioms) { return getOntology().addAxioms(axioms); }
/** * Update the ontology by adding or removing the given set of axioms * * @param ontology target ontology * @param axioms the axiom to add/remove * @param add true - add; false - delete */ public static void updateOntology(final OWLOntology ontology, final Stream<? extends OWLAxiom> axioms, final boolean add) { if (add) ontology.addAxioms(axioms); else ontology.removeAxioms(axioms); }
/** * Update the ontology by adding or removing the given set of axioms * * @param ontology target ontology * @param axioms the axiom to add/remove * @param add true - add; false - delete */ public static void updateOntology(final OWLOntology ontology, final Stream<? extends OWLAxiom> axioms, final boolean add) { if (add) ontology.addAxioms(axioms); else ontology.removeAxioms(axioms); }
/** * Update the ontology by adding or removing the given set of axioms * * @param ontology target ontology * @param axioms the axiom to add/remove * @param add true - add; false - delete */ public static void updateOntology(final OWLOntology ontology, final Stream<? extends OWLAxiom> axioms, final boolean add) { if (add) ontology.addAxioms(axioms); else ontology.removeAxioms(axioms); }
public static Optional<OWLOntology> load(final File file, final OWLOntologyManager manager, final Optional<OWLOntologyID> ontologyId) { final List<OWLAxiom> axioms = new ArrayList<>(); final OWLOntology ontology; try (final BufferedReader in = new BufferedReader(new FileReader(file))) { ontology = (ontologyId.isPresent()) ? manager.createOntology(ontologyId.get()) : manager.createOntology(); final OWLFunctionalSyntaxParser parser = new OWLFunctionalSyntaxParser(in); parser.setUp(ontology, new OWLOntologyLoaderConfiguration()); try { while (true) axioms.add(parser.Axiom()); } catch (@SuppressWarnings("unused") final Exception e) { // The exception is the way we detected the end. } } catch (final Exception exception) { Log.error(_logger, "Can't load the ontology from file " + file + ".", exception); return Optional.empty(); } ontology.addAxioms(axioms); return Optional.of(ontology); } }
public static Optional<OWLOntology> load(final File file, final OWLOntologyManager manager, final Optional<OWLOntologyID> ontologyId) { final List<OWLAxiom> axioms = new ArrayList<>(); final OWLOntology ontology; try (final BufferedReader in = new BufferedReader(new FileReader(file))) { ontology = (ontologyId.isPresent()) ? manager.createOntology(ontologyId.get()) : manager.createOntology(); final OWLFunctionalSyntaxParser parser = new OWLFunctionalSyntaxParser(in); parser.setUp(ontology, new OWLOntologyLoaderConfiguration()); try { while (true) axioms.add(parser.Axiom()); } catch (@SuppressWarnings("unused") final Exception e) { // The exception is the way we detected the end. } } catch (final Exception exception) { Log.error(_logger, "Can't load the ontology from file " + file + ".", exception); return Optional.empty(); } ontology.addAxioms(axioms); return Optional.of(ontology); } }
public static Optional<OWLOntology> load(final File file, final OWLOntologyManager manager, final Optional<OWLOntologyID> ontologyId) { final List<OWLAxiom> axioms = new ArrayList<>(); final OWLOntology ontology; try (final BufferedReader in = new BufferedReader(new FileReader(file))) { ontology = (ontologyId.isPresent()) ? manager.createOntology(ontologyId.get()) : manager.createOntology(); final OWLFunctionalSyntaxParser parser = new OWLFunctionalSyntaxParser(in); parser.setUp(ontology, new OWLOntologyLoaderConfiguration()); try { while (true) axioms.add(parser.Axiom()); } catch (@SuppressWarnings("unused") final Exception e) { // The exception is the way we detected the end. } } catch (final Exception exception) { Log.error(_logger, "Can't load the ontology from file " + file + ".", exception); return Optional.empty(); } ontology.addAxioms(axioms); return Optional.of(ontology); } }
/** * Removes all annotations (non-logical axioms) from the ontology causing the ontology to be changed in an unreversible way. For any entity that is only * referenced in an annotation but no logical axiom a declaration is added so that the referenced entities by the ontology remain same. Annotations have no * semantic importance and can be ignored for reasoning purposes including generating explanations and computing modules. Removing them from the ontology * completely reduces the memory requirements which is very high for large-scale annotation-heavy ontologies. * * @param ontology the ontology being changed */ public static void removeAllAnnotations(final OWLOntology ontology) { try { final Set<OWLEntity> referencedEntities = Stream.concat(// Stream.concat(ontology.classesInSignature(), ontology.objectPropertiesInSignature()), // Stream.concat(ontology.dataPropertiesInSignature(), ontology.individualsInSignature())// ).collect(Collectors.toSet()); // Remove every thing that is not logical. ontology.removeAxioms(ontology.axioms().filter(axiom -> !axiom.isLogicalAxiom())); final OWLDataFactory factory = ontology.getOWLOntologyManager().getOWLDataFactory(); // Add exactly once declaration per entity. ontology.addAxioms(referencedEntities.stream()// .filter(entity -> !ontology.containsEntityInSignature(entity))// .map(factory::getOWLDeclarationAxiom)// ); } catch (final OWLOntologyChangeException e) { throw new OWLRuntimeException(e); } }
/** * Removes all annotations (non-logical axioms) from the ontology causing the ontology to be changed in an unreversible way. For any entity that is only * referenced in an annotation but no logical axiom a declaration is added so that the referenced entities by the ontology remain same. Annotations have no * semantic importance and can be ignored for reasoning purposes including generating explanations and computing modules. Removing them from the ontology * completely reduces the memory requirements which is very high for large-scale annotation-heavy ontologies. * * @param ontology the ontology being changed */ public static void removeAllAnnotations(final OWLOntology ontology) { try { final Set<OWLEntity> referencedEntities = Stream.concat(// Stream.concat(ontology.classesInSignature(), ontology.objectPropertiesInSignature()), // Stream.concat(ontology.dataPropertiesInSignature(), ontology.individualsInSignature())// ).collect(Collectors.toSet()); // Remove every thing that is not logical. ontology.removeAxioms(ontology.axioms().filter(axiom -> !axiom.isLogicalAxiom())); final OWLDataFactory factory = ontology.getOWLOntologyManager().getOWLDataFactory(); // Add exactly once declaration per entity. ontology.addAxioms(referencedEntities.stream()// .filter(entity -> !ontology.containsEntityInSignature(entity))// .map(factory::getOWLDeclarationAxiom)// ); } catch (final OWLOntologyChangeException e) { throw new OWLRuntimeException(e); } }
/** * Removes all annotations (non-logical axioms) from the ontology causing the ontology to be changed in an unreversible way. For any entity that is only * referenced in an annotation but no logical axiom a declaration is added so that the referenced entities by the ontology remain same. Annotations have no * semantic importance and can be ignored for reasoning purposes including generating explanations and computing modules. Removing them from the ontology * completely reduces the memory requirements which is very high for large-scale annotation-heavy ontologies. * * @param ontology the ontology being changed */ public static void removeAllAnnotations(final OWLOntology ontology) { try { final Set<OWLEntity> referencedEntities = Stream.concat(// Stream.concat(ontology.classesInSignature(), ontology.objectPropertiesInSignature()), // Stream.concat(ontology.dataPropertiesInSignature(), ontology.individualsInSignature())// ).collect(Collectors.toSet()); // Remove every thing that is not logical. ontology.removeAxioms(ontology.axioms().filter(axiom -> !axiom.isLogicalAxiom())); final OWLDataFactory factory = ontology.getOWLOntologyManager().getOWLDataFactory(); // Add exactly once declaration per entity. ontology.addAxioms(referencedEntities.stream()// .filter(entity -> !ontology.containsEntityInSignature(entity))// .map(factory::getOWLDeclarationAxiom)// ); } catch (final OWLOntologyChangeException e) { throw new OWLRuntimeException(e); } }
final OWLNamedIndividual b = OWL.Individual("B"); ontology.addAxioms(//
final OWLNamedIndividual b = OWL.Individual("B"); ontology.addAxioms(//