/** * Remove tautologies (axioms that are always local) from the ontology * temporarily. * * @param o ontology */ void removeTautologies(Collection<AxiomWrapper> o) { // we might use it for another decomposition tautologies.clear(); for (AxiomWrapper p : o) { if (p.isUsed() && modularizer.isTautology(p.getAxiom(), type)) { tautologies.add(p); p.setUsed(false); } } }
/** * Add all the non-local axioms from given axiom-set AxSet. * * @param axSet axiom set * @param noCheck check or not */ void addNonLocal(Collection<AxiomWrapper> axSet, boolean noCheck) { for (AxiomWrapper q : axSet) { if (!q.isInModule() && q.isInSearchSpace()) { addNonLocal(q, noCheck); } } }
/** * @param ax axiom to add to the atom */ public void addAxiom(AxiomWrapper ax) { axioms.add(ax); ax.setAtom(this); }
/** * add an axiom to a module * * @param axiom axiom */ private void addAxiomToModule(AxiomWrapper axiom) { axiom.setInModule(true); module.add(axiom); // update the signature addAxiomSig(axiom.signature()); }
/** * extract module wrt presence of a sig index * * @param list axioms */ private void extractModule(Collection<AxiomWrapper> list) { module.clear(); // clear the module flag in the input list.forEach(p -> { p.setInModule(false); if (p.isUsed()) { p.setInSearchSpace(true); } }); extractModuleQueue(); list.forEach(p -> p.setInSearchSpace(false)); }
Set<OWLAxiom> asSet(Collection<AxiomWrapper> c) { Set<OWLAxiom> toReturn = new HashSet<>(); for (AxiomWrapper p : c) { toReturn.add(p.getAxiom()); } return toReturn; }
/** @return signature of all ontology axioms */ @PortedFrom(file = "tOntology.h", name = "getSignature") public Stream<Expression> signature() { return axioms.stream().filter(p -> p.isUsed()).flatMap(p -> ((AxiomImpl) p).namedEntitySignature()).distinct(); }
/** * restore all tautologies back */ private void restoreTautologies() { for (AxiomWrapper p : tautologies) { p.setUsed(true); } }
/** * extract module wrt presence of a sig index * * @param list axioms */ private void extractModule(Collection<AxiomWrapper> list) { module.clear(); // clear the module flag in the input list.forEach(p -> p.setInModule(false)); list.stream().filter(AxiomWrapper::isUsed).forEach(p -> p.setInSearchSpace(true)); extractModuleQueue(); list.forEach(p -> p.setInSearchSpace(false)); }
/** * Get module. * * @param sig signature * @param type type of module * @return module */ Collection<AxiomWrapper> getModule(Signature sig, ModuleType type) { return getModule(asList(ontology.axioms().map(a -> new AxiomWrapper(a))), sig, type); }
/** * add an axiom to a module * * @param axiom axiom */ private void addAxiomToModule(AxiomWrapper axiom) { axiom.setInModule(true); module.add(axiom); // update the signature addAxiomSig(axiom); }
/** * add an axiom if it is non-local (or in noCheck is true) * * @param ax axiom to add * @param noCheck check or not */ void addNonLocal(AxiomWrapper ax, boolean noCheck) { if (noCheck || isNonLocal(ax)) { addAxiomToModule(ax); if (noAtomsProcessing && ax.getAtom().isPresent()) { noAtomsProcessing = false; addNonLocal(ax.getAtom().get().getModule(), true); noAtomsProcessing = true; } } }
/** * extract module wrt presence of a sig index * * @param list axioms */ private void extractModule(Collection<AxiomWrapper> list) { module.clear(); // clear the module flag in the input list.forEach(p -> { p.setInModule(false); if (p.isUsed()) { p.setInSearchSpace(true); } }); extractModuleQueue(); list.forEach(p -> p.setInSearchSpace(false)); }
Set<OWLAxiom> asSet(Collection<AxiomWrapper> c) { Set<OWLAxiom> toReturn = new HashSet<>(); for (AxiomWrapper p : c) { toReturn.add(p.getAxiom()); } return toReturn; }
/** * process an axiom wrt its Used status * * @param ax the axiom to process */ public void processAx(AxiomWrapper ax) { if (ax.isUsed()) { registerAx(ax); } else { unregisterAx(ax); } }