/** * @param signature the signature to use * @param moduletype module type * @param useSemantics true if semantic locality should be used * @return a set of axioms that corresponds to the atom with the id INDEX */ public Collection<AxiomWrapper> getModule(Stream<OWLEntity> signature, boolean useSemantics, ModuleType moduletype) { // init signature Signature sig = new Signature(signature); sig.setLocality(false); modularizer.extract(axioms, sig, moduletype); return modularizer.getModule(); } }
/** * extract module wrt SIGNATURE and TYPE from the set of axioms * * @param axioms axiom * @param signature signature * @param type type */ public void extract(List<AxiomWrapper> axioms, Signature signature, ModuleType type) { boolean topLocality = type == ModuleType.TOP; sig = new Signature(signature.getSignature().stream()); checker.setSignatureValue(sig); sig.setLocality(topLocality); extractModule(axioms); if (type != ModuleType.STAR) { return; } // here there is a star: do the cycle until stabilization int size; do { size = module.size(); List<AxiomWrapper> oldModule = new ArrayList<>(module); topLocality = !topLocality; sig = new Signature(signature.getSignature().stream()); checker.setSignatureValue(sig); sig.setLocality(topLocality); extractModule(oldModule); } while (size != module.size()); }
@Override public void preprocessOntology(Collection<AxiomWrapper> axioms) { exprMap.clear(); Signature s = new Signature(); for (AxiomWrapper q : axioms) { if (q.isUsed()) { exprMap.putAll(q.getAxiom(), asList(getExpr(q.getAxiom()))); s.addAll(q.getAxiom().signature()); } } // register all the objects in the ontology signature Set<OWLAxiom> declarationAxioms = new HashSet<>(); for (OWLEntity p : s.getSignature()) { declarationAxioms.add(df.getOWLDeclarationAxiom(p)); } try { kernel = factory.createReasoner(manager.createOntology(declarationAxioms)); } catch (OWLOntologyCreationException e) { throw new OWLRuntimeException(e); } kernel.precomputeInferences(InferenceType.CLASS_HIERARCHY); }
/** * build a module traversing axioms by a signature */ private void extractModuleQueue() { // init queue with a sig workQueue.addAll(sig.getSignature()); // add all the axioms that are non-local wrt given value of a // top-locality addNonLocal(sigIndex.getNonLocal(sig.topCLocal()), true); // main cycle while (!workQueue.isEmpty()) { // for all the axioms that contains entity in their signature Collection<AxiomWrapper> axioms = sigIndex.getAxioms(workQueue.poll()); addNonLocal(axioms, false); } }
atom = buildModule(new Signature(ax.getAxiom().signature()), parent);
/** * setup Name2Sig for a given entity; * * @param entity * entity */ @PortedFrom(file = "Incremental.cpp", name = "setupSig") public void setupSig(@Nullable OWLEntity entity) { moduleTimer.start(); // do nothing if entity doesn't exist if (entity == null) { return; } moduleTimer.start(); // prepare a place to update Signature sig = new Signature(); // calculate a module sig.add(entity); getModExtractor(false, null).getModule(sig.getSignature().stream(), false, ModuleType.BOT); // perform update name2Sig.put(entity, new Signature(getModExtractor(false, null).getModularizer().getSignature().getSignature() .stream())); moduleTimer.stop(); }
/** * @param top set new locality polarity */ public void setLocality(boolean top) { this.setLocality(top, top); }
/** * @return true iff roles are treated as TOPs */ public boolean topRLocal() { return localityChecker.getSignature().topRLocal(); }
/** * @param sig signature elements */ public Signature(Stream<OWLEntity> sig) { addAll(sig); }
/** * @param entity * entity * @return true iff ENTRY is not in signature */ @PortedFrom(file = "tExpressionTranslator.h", name = "nc") private boolean nc(NamedEntity entity) { return sig != null && !sig.contains(entity.getEntity()); }
/** * build signature for ENTITY and all dependent entities from toProcess; * look for modules in Module; * * @param entity * entity * @param module * Module * @param toProcess * toProcess */ @PortedFrom(file = "Incremental.cpp", name = "buildSignature") public void buildSignature(OWLEntity entity, Collection<AxiomWrapper> module, Set<OWLEntity> toProcess) { toProcess.remove(entity); setupSig(entity); Collection<AxiomWrapper> newModule = getModExtractor(false, null).getModularizer().getModule(); if (module.size() == newModule.size()) { return; } // smaller module: recurse Signature modSig = getModExtractor(false, null).getModularizer().getSignature(); modSig.getSignature().stream().filter(toProcess::contains).forEach(p -> buildSignature(p, newModule, toProcess)); }
@Override public DLTree visit(ConceptName expr) { if (nc(expr)) { return sig.topCLocal() ? DLTreeFactory.createTop() : DLTreeFactory.createBottom(); } else { NamedEntry entry = expr.getEntry(); if (entry == null) { entry = matchEntry(tbox.getConcept(expr.getIRI()), expr); } return DLTreeFactory.buildTree(new Lexeme(CNAME, entry)); } }
@Override public void preprocessOntology(Collection<AxiomWrapper> axioms) { exprMap.clear(); Signature s = new Signature(); for (AxiomWrapper q : axioms) { if (q.isUsed()) { exprMap.putAll(q.getAxiom(), asList(getExpr(q.getAxiom()))); s.addAll(q.getAxiom().signature()); } } // register all the objects in the ontology signature Set<OWLAxiom> declarationAxioms = new HashSet<>(); for (OWLEntity p : s.getSignature()) { declarationAxioms.add(df.getOWLDeclarationAxiom(p)); } try { kernel = factory.createReasoner(manager.createOntology(declarationAxioms)); } catch (OWLOntologyCreationException e) { throw new OWLRuntimeException(e); } kernel.precomputeInferences(InferenceType.CLASS_HIERARCHY); }
/** * build a module traversing axioms by a signature */ private void extractModuleQueue() { // init queue with a sig workQueue.addAll(sig.getSignature()); // add all the axioms that are non-local wrt given value of a // top-locality addNonLocal(sigIndex.getNonLocal(sig.topCLocal()), true); // main cycle while (!workQueue.isEmpty()) { // for all the axioms that contains entity in their signature Collection<AxiomWrapper> axioms = sigIndex.getAxioms(workQueue.poll()); addNonLocal(axioms, false); } }
atom = buildModule(new Signature(ax.getAxiom().signature()), parent);