@Override public Taxonomy<ATermAppl> getObjectTaxonomy() { if (_objectTaxonomy == null) { final RoleTaxonomyBuilder builder = new RoleTaxonomyBuilder(this, PropertyType.OBJECT); _objectTaxonomy = builder.classify(); } return _objectTaxonomy; }
private Collection<TaxonomyNode<ATermAppl>> search(final boolean topSearch, final Role c, final TaxonomyNode<ATermAppl> x, final Set<TaxonomyNode<ATermAppl>> visited, final List<TaxonomyNode<ATermAppl>> result, final Map<TaxonomyNode<ATermAppl>, Boolean> marked) { final List<TaxonomyNode<ATermAppl>> posSucc = new ArrayList<>(); visited.add(x); final Collection<TaxonomyNode<ATermAppl>> list = topSearch ? x.getSubs() : x.getSupers(); for (final TaxonomyNode<ATermAppl> next : list) if (topSearch) { if (subsumes(next, c, marked)) posSucc.add(next); } else if (subsumed(next, c, marked)) posSucc.add(next); if (posSucc.isEmpty()) result.add(x); else for (final TaxonomyNode<ATermAppl> y : posSucc) if (!visited.contains(y)) search(topSearch, c, y, visited, result, marked); return result; }
mark(_taxonomyImpl.getTop(), marked, Boolean.TRUE, Propagate.NONE); mark(_taxonomyImpl.getBottomNode(), marked, Boolean.FALSE, Propagate.NONE); final Collection<TaxonomyNode<ATermAppl>> superNodes = search(true, c, _taxonomyImpl.getTop(), new HashSet<TaxonomyNode<ATermAppl>>(), new ArrayList<TaxonomyNode<ATermAppl>>(), marked); mark(_taxonomyImpl.getTop(), marked, Boolean.FALSE, Propagate.NONE); mark(_taxonomyImpl.getBottomNode(), marked, Boolean.TRUE, Propagate.NONE); if (subsumed(sup, c, marked)) final Collection<TaxonomyNode<ATermAppl>> subNodes = search(false, c, _taxonomyImpl.getBottomNode(), new HashSet<TaxonomyNode<ATermAppl>>(), new ArrayList<TaxonomyNode<ATermAppl>>(), marked);
private boolean subsumes(final TaxonomyNode<ATermAppl> node, final Role c, final Map<TaxonomyNode<ATermAppl>, Boolean> marked) { final Boolean cached = marked.get(node); if (cached != null) return cached.booleanValue(); // check subsumption final boolean subsumes = subsumes(_rbox.getRole(node.getName()), c); // create an object based on result final Boolean value = subsumes ? Boolean.TRUE : Boolean.FALSE; // during top search only negative information is propagated down final Propagate propagate = subsumes ? Propagate.NONE : Propagate.DOWN; // mark the _node appropriately mark(node, marked, value, propagate); return subsumes; }
public Taxonomy<ATermAppl> classify() { if (_logger.isLoggable(Level.FINE)) _logger.fine("Properties: " + _properties.size()); for (final Role r : _properties) { if (_propertyType != r.getType()) continue; classify(r); } return _taxonomyImpl; }
private void mark(final TaxonomyNode<ATermAppl> node, final Map<TaxonomyNode<ATermAppl>, Boolean> marked, final Boolean value, final Propagate propagate) { final Boolean exists = marked.get(node); if (exists != null) if (!exists.equals(value)) throw new OpenError("Inconsistent classification result " + node.getName() + " " + exists + " " + value); else return; marked.put(node, value); if (propagate != Propagate.NONE) { final Collection<TaxonomyNode<ATermAppl>> others = propagate == Propagate.UP ? node.getSupers() : node.getSubs(); for (final TaxonomyNode<ATermAppl> next : others) mark(next, marked, value, propagate); } }
private Collection<TaxonomyNode<ATermAppl>> search(final boolean topSearch, final Role c, final TaxonomyNode<ATermAppl> x, final Set<TaxonomyNode<ATermAppl>> visited, final List<TaxonomyNode<ATermAppl>> result, final Map<TaxonomyNode<ATermAppl>, Boolean> marked) { final List<TaxonomyNode<ATermAppl>> posSucc = new ArrayList<>(); visited.add(x); final Collection<TaxonomyNode<ATermAppl>> list = topSearch ? x.getSubs() : x.getSupers(); for (final TaxonomyNode<ATermAppl> next : list) if (topSearch) { if (subsumes(next, c, marked)) posSucc.add(next); } else if (subsumed(next, c, marked)) posSucc.add(next); if (posSucc.isEmpty()) result.add(x); else for (final TaxonomyNode<ATermAppl> y : posSucc) if (!visited.contains(y)) search(topSearch, c, y, visited, result, marked); return result; }
mark(_taxonomyImpl.getTop(), marked, Boolean.TRUE, Propagate.NONE); mark(_taxonomyImpl.getBottomNode(), marked, Boolean.FALSE, Propagate.NONE); final Collection<TaxonomyNode<ATermAppl>> superNodes = search(true, c, _taxonomyImpl.getTop(), new HashSet<TaxonomyNode<ATermAppl>>(), new ArrayList<TaxonomyNode<ATermAppl>>(), marked); mark(_taxonomyImpl.getTop(), marked, Boolean.FALSE, Propagate.NONE); mark(_taxonomyImpl.getBottomNode(), marked, Boolean.TRUE, Propagate.NONE); if (subsumed(sup, c, marked)) final Collection<TaxonomyNode<ATermAppl>> subNodes = search(false, c, _taxonomyImpl.getBottomNode(), new HashSet<TaxonomyNode<ATermAppl>>(), new ArrayList<TaxonomyNode<ATermAppl>>(), marked);
private boolean subsumed(final TaxonomyNode<ATermAppl> node, final Role c, final Map<TaxonomyNode<ATermAppl>, Boolean> marked) { final Boolean cached = marked.get(node); if (cached != null) return cached.booleanValue(); // check subsumption final boolean subsumed = subsumes(c, _rbox.getRole(node.getName())); // create an object based on result final Boolean value = subsumed ? Boolean.TRUE : Boolean.FALSE; // during bottom search only negative information is propagated down final Propagate propagate = subsumed ? Propagate.NONE : Propagate.UP; // mark the _node appropriately mark(node, marked, value, propagate); return subsumed; }
public Taxonomy<ATermAppl> classify() { if (_logger.isLoggable(Level.FINE)) _logger.fine("Properties: " + _properties.size()); for (final Role r : _properties) { if (_propertyType != r.getType()) continue; classify(r); } return _taxonomyImpl; }
private void mark(final TaxonomyNode<ATermAppl> node, final Map<TaxonomyNode<ATermAppl>, Boolean> marked, final Boolean value, final Propagate propagate) { final Boolean exists = marked.get(node); if (exists != null) if (!exists.equals(value)) throw new OpenError("Inconsistent classification result " + node.getName() + " " + exists + " " + value); else return; marked.put(node, value); if (propagate != Propagate.NONE) { final Collection<TaxonomyNode<ATermAppl>> others = propagate == Propagate.UP ? node.getSupers() : node.getSubs(); for (final TaxonomyNode<ATermAppl> next : others) mark(next, marked, value, propagate); } }
@Override public Taxonomy<ATermAppl> getObjectTaxonomy() { if (_objectTaxonomy == null) { final RoleTaxonomyBuilder builder = new RoleTaxonomyBuilder(this, PropertyType.OBJECT); _objectTaxonomy = builder.classify(); } return _objectTaxonomy; }
private boolean subsumed(final TaxonomyNode<ATermAppl> node, final Role c, final Map<TaxonomyNode<ATermAppl>, Boolean> marked) { final Boolean cached = marked.get(node); if (cached != null) return cached.booleanValue(); // check subsumption final boolean subsumed = subsumes(c, _rbox.getRole(node.getName())); // create an object based on result final Boolean value = subsumed ? Boolean.TRUE : Boolean.FALSE; // during bottom search only negative information is propagated down final Propagate propagate = subsumed ? Propagate.NONE : Propagate.UP; // mark the _node appropriately mark(node, marked, value, propagate); return subsumed; }
@Override public Taxonomy<ATermAppl> getAnnotationTaxonomy() { if (_annotationTaxonomy == null) { final RoleTaxonomyBuilder builder = new RoleTaxonomyBuilder(this, PropertyType.ANNOTATION); if (OpenlletOptions.USE_ANNOTATION_SUPPORT) _annotationTaxonomy = builder.classify(); } return _annotationTaxonomy; }
private boolean subsumes(final TaxonomyNode<ATermAppl> node, final Role c, final Map<TaxonomyNode<ATermAppl>, Boolean> marked) { final Boolean cached = marked.get(node); if (cached != null) return cached.booleanValue(); // check subsumption final boolean subsumes = subsumes(_rbox.getRole(node.getName()), c); // create an object based on result final Boolean value = subsumes ? Boolean.TRUE : Boolean.FALSE; // during top search only negative information is propagated down final Propagate propagate = subsumes ? Propagate.NONE : Propagate.DOWN; // mark the _node appropriately mark(node, marked, value, propagate); return subsumes; }
@Override public Taxonomy<ATermAppl> getDataTaxonomy() { if (_dataTaxonomy == null) { final RoleTaxonomyBuilder builder = new RoleTaxonomyBuilder(this, PropertyType.DATATYPE); _dataTaxonomy = builder.classify(); } return _dataTaxonomy; }
@Override public Taxonomy<ATermAppl> getAnnotationTaxonomy() { if (_annotationTaxonomy == null) { final RoleTaxonomyBuilder builder = new RoleTaxonomyBuilder(this, PropertyType.ANNOTATION); if (OpenlletOptions.USE_ANNOTATION_SUPPORT) _annotationTaxonomy = builder.classify(); } return _annotationTaxonomy; }
@Override public Taxonomy<ATermAppl> getDataTaxonomy() { if (_dataTaxonomy == null) { final RoleTaxonomyBuilder builder = new RoleTaxonomyBuilder(this, PropertyType.DATATYPE); _dataTaxonomy = builder.classify(); } return _dataTaxonomy; }