/** * @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; }
/** * @param r * @return true if the term is declared as a role */ default boolean isRole(final ATerm r) { return getRoles().containsKey(r); }
/** * @param r Name (URI) of the role * @return the role with the given name and throw and exception if it is not found. */ default Role getDefinedRole(final ATerm r) { final Role role = getRoles().get(r); if (role == null) throw new OpenError(r + " is not defined as a property"); return role; }
/** * @param r Name (URI) of the role * @return the role with the given name and throw and exception if it is not found. */ default Role getDefinedRole(final ATerm r) { final Role role = getRoles().get(r); if (role == null) throw new OpenError(r + " is not defined as a property"); return role; }
default Role addRole(final ATermAppl r) { Role role = getRole(r); if (role == null) { role = new RoleImpl(r, PropertyType.UNTYPED); getRoles().put(r, role); } return role; }
default Role addRole(final ATermAppl r) { Role role = getRole(r); if (role == null) { role = new RoleImpl(r, PropertyType.UNTYPED); getRoles().put(r, role); } return role; }
default Set<ATermAppl> getTransitiveProperties() { final Set<ATermAppl> set = new HashSet<>(); for (final Role role : getRBox().getRoles().values()) { final ATermAppl p = role.getName(); if (ATermUtils.isPrimitive(p) && role.isTransitive()) set.add(p); } set.add(ATermUtils.BOTTOM_OBJECT_PROPERTY); return set; }
default Set<ATermAppl> getTransitiveProperties() { final Set<ATermAppl> set = new HashSet<>(); for (final Role role : getRBox().getRoles().values()) { final ATermAppl p = role.getName(); if (ATermUtils.isPrimitive(p) && role.isTransitive()) set.add(p); } set.add(ATermUtils.BOTTOM_OBJECT_PROPERTY); return set; }
default Set<ATermAppl> getAnnotationProperties() { final Set<ATermAppl> set = new HashSet<>(); for (final Role role : getRBox().getRoles().values()) { final ATermAppl p = role.getName(); if (ATermUtils.isPrimitive(p) && role.isAnnotationRole()) set.add(p); } return set; }
default Set<ATermAppl> getIrreflexiveProperties() { final Set<ATermAppl> set = new HashSet<>(); for (final Role role : getRBox().getRoles().values()) { final ATermAppl p = role.getName(); if (ATermUtils.isPrimitive(p) && role.isIrreflexive()) set.add(p); } return set; }
default Set<ATermAppl> getIrreflexiveProperties() { final Set<ATermAppl> set = new HashSet<>(); for (final Role role : getRBox().getRoles().values()) { final ATermAppl p = role.getName(); if (ATermUtils.isPrimitive(p) && role.isIrreflexive()) set.add(p); } return set; }
default Set<ATermAppl> getAsymmetricProperties() { final Set<ATermAppl> set = new HashSet<>(); for (final Role role : getRBox().getRoles().values()) { final ATermAppl p = role.getName(); if (ATermUtils.isPrimitive(p) && role.isAsymmetric()) set.add(p); } return set; }
default Set<ATermAppl> getSymmetricProperties() { final Set<ATermAppl> set = new HashSet<>(); for (final Role role : getRBox().getRoles().values()) { final ATermAppl p = role.getName(); if (ATermUtils.isPrimitive(p) && role.isSymmetric()) set.add(p); } return set; }
default Set<ATermAppl> getAsymmetricProperties() { final Set<ATermAppl> set = new HashSet<>(); for (final Role role : getRBox().getRoles().values()) { final ATermAppl p = role.getName(); if (ATermUtils.isPrimitive(p) && role.isAsymmetric()) set.add(p); } return set; }
default Set<ATermAppl> getReflexiveProperties() { final Set<ATermAppl> set = new HashSet<>(); for (final Role role : getRBox().getRoles().values()) { final ATermAppl p = role.getName(); if (ATermUtils.isPrimitive(p) && role.isReflexive()) set.add(p); } return set; }
default Set<ATermAppl> getSymmetricProperties() { final Set<ATermAppl> set = new HashSet<>(); for (final Role role : getRBox().getRoles().values()) { final ATermAppl p = role.getName(); if (ATermUtils.isPrimitive(p) && role.isSymmetric()) set.add(p); } return set; }
default Set<ATermAppl> getReflexiveProperties() { final Set<ATermAppl> set = new HashSet<>(); for (final Role role : getRBox().getRoles().values()) { final ATermAppl p = role.getName(); if (ATermUtils.isPrimitive(p) && role.isReflexive()) set.add(p); } return set; }
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)); } }
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)); } }
public static ATermAppl selectRandomObjectProperty(final KnowledgeBaseImpl kb) { //get all classes final List<Role> roles = new ArrayList<>(kb.getRBox().getRoles().values()); Role role = null; do { role = roles.get(_rand.nextInt(roles.size())); } while (!role.isObjectRole()); return role.getName(); }