/** * @param term * @return a role */ public default Role getRole(final ATerm term) { return getRBox().getRole(term); }
/** * @param r Name (URI) of the role * @return the role with the given name */ default Role getRole(final ATerm r) { return null != r ? getRoles().get(r) : null; }
default Taxonomy<ATermAppl> getRoleTaxonomy(final boolean objectTaxonomy) { prepare(); return objectTaxonomy ? getRBox().getObjectTaxonomy() : getRBox().getDataTaxonomy(); }
default void propagateDomainRange() { for (final Role role : getRoles().values()) role.resetDomainRange(); for (final Role role : getRoles().values()) { final Role invRole = role.getInverse(); if (invRole != null) { final Map<ATermAppl, Set<Set<ATermAppl>>> invDomains = getDomainAssertions().get(invRole); final Map<ATermAppl, Set<Set<ATermAppl>>> invRanges = getRangeAssertions().get(invRole); propogateDomain(role, invRanges); propogateRange(role, invDomains); } final Map<ATermAppl, Set<Set<ATermAppl>>> domains = getDomainAssertions().get(role); final Map<ATermAppl, Set<Set<ATermAppl>>> ranges = getRangeAssertions().get(role); propogateDomain(role, domains); propogateRange(role, ranges); } }
default boolean removeRange(final ATerm p, final ATermAppl range) { if (!OpenlletOptions.USE_TRACING) return false; final Role r = getRole(p); if (r == null) return false; final Map<ATermAppl, Set<Set<ATermAppl>>> ranges = getRangeAssertions().get(r); if (ranges == null) return false; final Set<Set<ATermAppl>> allExplanations = ranges.get(range); if (allExplanations == null) return false; final Set<ATermAppl> explanation = Collections.singleton(ATermUtils.makeRange(p, range)); if (!allExplanations.remove(explanation)) return false; if (allExplanations.isEmpty()) ranges.remove(range); return true; }
default boolean addInverseRole(final ATerm s, final ATerm r, final DependencySet ds) { final Role roleS = getRole(s); final Role roleR = getRole(r); if (roleS == null || roleR == null || !roleS.isObjectRole() || !roleR.isObjectRole()) return false; else addEquivalentRole(roleS.getInverse().getName(), r, ds); return true; }
private void prepareDomainsRanges(final RBox rbox) { for (final Role role : rbox.getRoles().values()) { final Iterator<ATermAppl> assertedDomains = rbox.getAssertedDomains(role); if (assertedDomains.hasNext()) addTo(_domains, role.getName(), IteratorUtils.toSet(assertedDomains)); final Iterator<ATermAppl> assertedRanges = rbox.getAssertedRanges(role); if (assertedRanges.hasNext()) addTo(_ranges, role.getName(), IteratorUtils.toSet(assertedRanges)); } }
default Taxonomy<ATermAppl> getRoleTaxonomy(final ATermAppl r) { prepare(); if (isObjectProperty(r)) return getRBox().getObjectTaxonomy(); else if (isDatatypeProperty(r)) return getRBox().getDataTaxonomy(); else if (isAnnotationProperty(r)) return getRBox().getAnnotationTaxonomy(); return null; }
default boolean removeDomain(final ATerm p, final ATermAppl domain) { if (!OpenlletOptions.USE_TRACING) return false; final Role r = getRole(p); if (r == null) return false; final Map<ATermAppl, Set<Set<ATermAppl>>> domains = getDomainAssertions().get(r); if (domains == null) return false; final Set<Set<ATermAppl>> allExplanations = domains.get(domain); if (allExplanations == null) return false; final Set<ATermAppl> explanation = Collections.singleton(ATermUtils.makeDomain(p, domain)); if (!allExplanations.remove(explanation)) return false; if (allExplanations.isEmpty()) domains.remove(domain); return true; }
/** * For internal use when domain axioms come from TBox absorption */ @Override public void addDomain(final ATerm p, final ATermAppl c, final Set<ATermAppl> explain) { _changes.add(ChangeType.RBOX_ADD); _rbox.addDomain(p, c, explain); _logger.finer(() -> "domain " + p + " " + c + " " + explain); }
default boolean addEquivalentRole(final ATerm s, final ATerm r) { final DependencySet ds = OpenlletOptions.USE_TRACING ? new DependencySet(ATermUtils.makeEqProp(s, r)) : DependencySet.INDEPENDENT; return addEquivalentRole(r, s, ds); }
default void addDisjointProperty(final ATermAppl p1, final ATermAppl p2, final DependencySet ds) { getChanges().add(ChangeType.RBOX_ADD); getRBox().addDisjointRole(p1, p2, ds); getLogger().finer(() -> "dis-prop " + p1 + " " + p2); }
@Override public boolean addAnnotationProperty(final ATerm p) { if (null == p) return false; final boolean exists = getPropertyType(p) == PropertyType.ANNOTATION; final Role role = _rbox.addAnnotationRole((ATermAppl) p); if (!exists) { _changes.add(ChangeType.RBOX_ADD); _logger.finer(() -> "annotation-prop " + p); } return role != null; }
/** * Add a new object property. If property was earlier defined to be a datatype property then this function will simply return without changing the KB. * * @param p * @return True if property is added, false if not */ @Override public boolean addDatatypeProperty(final ATerm p) { if (null == p) return false; final boolean exists = getPropertyType(p) == PropertyType.DATATYPE; final Role role = _rbox.addDatatypeRole((ATermAppl) p); if (!exists) { _changes.add(ChangeType.RBOX_ADD); _logger.finer(() -> "data-prop " + p); } return role != null; }
default void propagateDomainRange() { for (final Role role : getRoles().values()) role.resetDomainRange(); for (final Role role : getRoles().values()) { final Role invRole = role.getInverse(); if (invRole != null) { final Map<ATermAppl, Set<Set<ATermAppl>>> invDomains = getDomainAssertions().get(invRole); final Map<ATermAppl, Set<Set<ATermAppl>>> invRanges = getRangeAssertions().get(invRole); propogateDomain(role, invRanges); propogateRange(role, invDomains); } final Map<ATermAppl, Set<Set<ATermAppl>>> domains = getDomainAssertions().get(role); final Map<ATermAppl, Set<Set<ATermAppl>>> ranges = getRangeAssertions().get(role); propogateDomain(role, domains); propogateRange(role, ranges); } }
default boolean addInverseRole(final ATerm s, final ATerm r, final DependencySet ds) { final Role roleS = getRole(s); final Role roleR = getRole(r); if (roleS == null || roleR == null || !roleS.isObjectRole() || !roleR.isObjectRole()) return false; else addEquivalentRole(roleS.getInverse().getName(), r, ds); return true; }
private void prepareDomainsRanges(final RBox rbox) { for (final Role role : rbox.getRoles().values()) { final Iterator<ATermAppl> assertedDomains = rbox.getAssertedDomains(role); if (assertedDomains.hasNext()) addTo(_domains, role.getName(), IteratorUtils.toSet(assertedDomains)); final Iterator<ATermAppl> assertedRanges = rbox.getAssertedRanges(role); if (assertedRanges.hasNext()) addTo(_ranges, role.getName(), IteratorUtils.toSet(assertedRanges)); } }
default Taxonomy<ATermAppl> getRoleTaxonomy(final ATermAppl r) { prepare(); if (isObjectProperty(r)) return getRBox().getObjectTaxonomy(); else if (isDatatypeProperty(r)) return getRBox().getDataTaxonomy(); else if (isAnnotationProperty(r)) return getRBox().getAnnotationTaxonomy(); return null; }