private boolean add(final ATermAppl r1, final ATermAppl r2, final ATermAppl superRole) { MultiValueMap<ATermAppl, ATermAppl> innerMap = _binaryRoleInclusions.get(r1); if (innerMap == null) { innerMap = new MultiValueMap<>(); _binaryRoleInclusions.put(r1, innerMap); } return innerMap.add(r2, superRole); }
private static Bool checkDisjointPropertyClash(final CachedNode root1, final CachedNode root2) { final MultiValueMap<ATermAppl, Role> neighbors1 = collectNeighbors(root1); if (neighbors1.isEmpty()) return null; final MultiValueMap<ATermAppl, Role> neighbors2 = collectNeighbors(root2); if (neighbors2.isEmpty()) return null; for (final Entry<ATermAppl, Set<Role>> e : neighbors1.entrySet()) { final ATermAppl commonNeighbor = e.getKey(); final Set<Role> roles1 = e.getValue(); final Set<Role> roles2 = neighbors2.get(commonNeighbor); if (roles2 == null) continue; if (checkDisjointProperties(roles1, roles2)) return Bool.UNKNOWN; } return null; }
public ConceptInfo(final ATermAppl c, final boolean storeSuccessors, final boolean noTriggers) { _concept = c; _successors = storeSuccessors ? new MultiValueMap<>() : null; _predecessors.clear(); _triggers = noTriggers ? null : SetUtils.create(); }
private void processDeletions() { for (final OWLAxiom axiom : _deletions) { _axioms.remove(axiom); axiom.signature().forEach(entity -> { _entityAxioms.remove(entity, axiom); if (!_entityAxioms.containsKey(entity)) { _logger.fine(() -> "Remove " + entity + " which is not mentioned anymore"); _modules.remove(entity); } }); } }
private OWLEntity extractModuleSignature(final OWLEntity entity, final Set<OWLEntity> stackElements, final List<OWLEntity> currentCycle, final Set<OWLEntity> module) assert !_modules.containsKey(entity) : "po already contained entity"; stackElements.add(entity); _modules.put(entity, module); if (!_modules.containsKey(member)) module.addAll(_modules.get(member)); _modules.put(e, module);
public boolean contains(final K key, final V value) { final Set<V> values = get(key); if (null == values) return false; return values.contains(value); }
final Iterator<ConceptInfo> preds = sub.getPredecessors().flattenedValues(); while (preds.hasNext()) addToQueue(preds.next(), sup); assert ATermUtils.isPrimitive(c); final Set<ConceptInfo> referredConjunctions = _conjunctions.get(sup); if (referredConjunctions != null) for (final ConceptInfo conjunction : referredConjunctions) for (final Entry<ATermAppl, Set<ConceptInfo>> e : sub.getPredecessors().entrySet()) if (_existentials.contains(superRole.getName(), sup))
public Taxonomy<ATermAppl> build(final MultiValueMap<ATermAppl, ATermAppl> subsumers) { _subsumers = subsumers; _taxonomyImpl = new TaxonomyImpl<>(null, ATermUtils.TOP, ATermUtils.BOTTOM); for (final ATermAppl subsumer : subsumers.get(ATermUtils.TOP)) if (ATermUtils.isPrimitive(subsumer)) _taxonomyImpl.addEquivalentNode(subsumer, _taxonomyImpl.getTop()); for (final Entry<ATermAppl, Set<ATermAppl>> entry : subsumers.entrySet()) { final ATermAppl c = entry.getKey(); if (ATermUtils.isPrimitive(c)) if (entry.getValue().contains(ATermUtils.BOTTOM)) _taxonomyImpl.addEquivalentNode(c, _taxonomyImpl.getBottomNode()); else add(c); } return _taxonomyImpl; }
private void processAdditions() { for (final OWLAxiom axiom : _additions) { _axioms.add(axiom); axiom.signature().forEach(entity -> { _entityAxioms.add(entity, axiom); if (entity instanceof OWLClass) { final OWLClass cls = (OWLClass) entity; if (_modules != null && !_modules.containsKey(cls)) _newClasses.add(cls); } }); } }
/** * Reads information about the modules from the input stream that has the information stored in a form of ontology. * * @param inputStream the input stream from which the ontology should be read * @return the read information about the modules * @throws IOException if an error occurs during the read process. */ public static MultiValueMap<OWLEntity, OWLEntity> loadModules(final InputStream is) throws IOException { final MultiValueMap<OWLEntity, OWLEntity> modules = new MultiValueMap<>(); final LineNumberReader lnr = new LineNumberReader(new InputStreamReader(is)); while (readModule(lnr, modules)) { // nothing to do } return modules; } }
/** * Clear the visitor _cache about simple properties. Should be called before a reload. */ public void clear() { _unsupportedAxioms.clear(); _compositePropertyAxioms.clear(); _simpleProperties.clear(); }
/** * Saves the information about modules from ModuleExtractor to an output stream as an ontology of modules annotated with URIs of the OWL entities that * belong to the respective modules. * * @param modules the modules to be saved * @param outputStream the output stream where the _data should be saved * @throws IOException if an error should occur during the save process */ public static void saveModules(final MultiValueMap<OWLEntity, OWLEntity> modules, final OutputStream outputStream) { final PrintWriter pw = new PrintWriter(outputStream); for (final Entry<OWLEntity, Set<OWLEntity>> entry : modules.entrySet()) { final OWLEntity entity = entry.getKey(); final Set<OWLEntity> module = entry.getValue(); pw.println(getModuleBegin(entity)); for (final OWLEntity member : module) pw.println(getModuleMember(member)); pw.println(getModuleEnd()); } pw.flush(); }
private static MultiValueMap<ATermAppl, Role> collectNeighbors(final CachedNode ind) { final MultiValueMap<ATermAppl, Role> neighbors = new MultiValueMap<>(); for (final Edge edge : ind.getInEdges()) { final Role role = edge.getRole(); final ATermAppl neighbor = edge.getFromName(); if (!ATermUtils.isBnode(neighbor)) neighbors.putSingle(neighbor, role); } for (final Edge edge : ind.getOutEdges()) { final Role role = edge.getRole(); final ATermAppl neighbor = edge.getToName(); if (role.isObjectRole() && !ATermUtils.isBnode(neighbor)) neighbors.putSingle(neighbor, role.getInverse()); } return neighbors; }
/** * Extract modules from scratch * * @return */ @Override public MultiValueMap<OWLEntity, OWLEntity> extractModules() { final Optional<Timer> timer = _timers.startTimer("extractModules"); // _cache the axiom signatures processAdditions(); _additions.clear(); // no need to consider _deletions for initial module extraction _deletions.clear(); _changes.clear(); _nonLocalAxioms = false; _modules = new MultiValueMap<>(); extractModuleSignatures(_entityAxioms.keySet()); timer.ifPresent(t -> t.stop()); return _modules; }
_aboxAssertions.remove(AssertionType.TYPE, typeAxiom);
/** * {@inheritDoc} */ @Override public Set<OWLAxiom> extractModule(final Set<? extends OWLEntity> signature) { if (isChanged()) resetModules(); final Set<OWLEntity> module = new HashSet<>(signature); axioms()// .filter(axiom -> !isLocal(axiom, Collections.<OWLEntity> emptySet())) // .forEach(axiom -> module.addAll(axiom.signature().collect(Collectors.toList()))); if (!_entityAxioms.isEmpty()) if (_optimizeForSharedModules) extractModuleSignature(null, new HashSet<OWLEntity>(), new ArrayList<OWLEntity>(), module); else extractModuleSignature(null, new DisjointSet<OWLEntity>(), new ArrayList<OWLEntity>(), module); return getModuleAxioms(module); }