/** * @param node * @param type * @return true if a type should be readded to a node */ private static boolean requiredAddType(final Node node, final ATermAppl type) { return !(type == null || node.hasType(type) && !ATermUtils.isAnd(type)); }
/** * @param node * @param type * @return true if a type should be readded to a node */ private static boolean requiredAddType(final Node node, final ATermAppl type) { return !(type == null || node.hasType(type) && !ATermUtils.isAnd(type)); }
protected void applyAllValues(final Individual subj, final Role pred, final Node obj, final ATermAppl c, final DependencySet ds) { if (!obj.hasType(c)) { _logger.fine(() -> "ALL : " + subj + " -> " + pred + " -> " + obj + " : " + ATermUtils.toString(c) + " - " + ds); // because we do not maintain the _queue it could be the case that this _node is pruned, so return if (obj.isPruned()) return; _strategy.addType(obj, c, ds); } }
protected void applyAllValues(final Individual subj, final Role pred, final Node obj, final ATermAppl c, final DependencySet ds) { if (!obj.hasType(c)) { _logger.fine(() -> "ALL : " + subj + " -> " + pred + " -> " + obj + " : " + ATermUtils.toString(c) + " - " + ds); // because we do not maintain the _queue it could be the case that this _node is pruned, so return if (obj.isPruned()) return; _strategy.addType(obj, c, ds); } }
final public Set<Node> getRSuccessors(final Role r, final ATermAppl c) { final Set<Node> result = new HashSet<>(); final EdgeList edges = _outEdges.getEdges(r); for (int i = 0, n = edges.size(); i < n; i++) { final Edge edge = edges.get(i); final Node other = edge.getNeighbor(this); if (other.hasType(c)) result.add(other); } return result; }
final public Set<Node> getRSuccessors(final Role r, final ATermAppl c) { final Set<Node> result = new HashSet<>(); final EdgeList edges = _outEdges.getEdges(r); for (int i = 0, n = edges.size(); i < n; i++) { final Edge edge = edges.get(i); final Node other = edge.getNeighbor(this); if (other.hasType(c)) result.add(other); } return result; }
@Override public void activate(final Token token) { resetDependencySet(token); final Node s = getNode(_subject, token); if (!s.hasType(_type)) _strategy.addType(s, _type, _ds); }
@Override public void activate(final Token token) { resetDependencySet(token); final Node s = getNode(_subject, token); if (!s.hasType(_type)) _strategy.addType(s, _type, _ds); }
if (!ATermUtils.isTop(c) && !neighbor.hasType(c)) continue; else
if (!ATermUtils.isTop(c) && !neighbor.hasType(c)) continue; else
if (super.hasType(type)) return true; else
if (super.hasType(type)) return true; else
/** * Apply all values restriction for the Top object role * * @param allTopC * @param c * @param ds */ public void applyAllValuesTop(final ATermAppl allTopC, final ATermAppl c, final DependencySet ds) { for (final Node node : _strategy.getABox().getNodes().values()) if (node.isIndividual() && !node.isPruned() && !node.hasType(c)) { node.addType(c, ds); node.addType(allTopC, ds); if (_strategy.getABox().isClosed()) break; } } }
/** * Apply all values restriction for the Top object role * * @param allTopC * @param c * @param ds */ public void applyAllValuesTop(final ATermAppl allTopC, final ATermAppl c, final DependencySet ds) { for (final Node node : _strategy.getABox().getNodes().values()) if (node.isIndividual() && !node.isPruned() && !node.hasType(c)) { node.addType(c, ds); node.addType(allTopC, ds); if (_strategy.getABox().isClosed()) break; } } }
public void applyDomainRange(final Individual subj, final Role pred, final Node obj, final DependencySet ds) { final Set<ATermAppl> domains = pred.getDomains(); final Set<ATermAppl> ranges = pred.getRanges(); for (final ATermAppl domain : domains) { if (_logger.isLoggable(Level.FINE) && !subj.hasType(domain)) _logger.fine("DOM : " + obj + " <- " + pred + " <- " + subj + " : " + ATermUtils.toString(domain)); addType(subj, domain, ds.union(pred.getExplainDomain(domain), _abox.doExplanation())); if (subj.isPruned() || obj.isPruned()) return; } for (final ATermAppl range : ranges) { if (_logger.isLoggable(Level.FINE) && !obj.hasType(range)) _logger.fine("RAN : " + subj + " -> " + pred + " -> " + obj + " : " + ATermUtils.toString(range)); addType(obj, range, ds.union(pred.getExplainRange(range), _abox.doExplanation())); if (subj.isPruned() || obj.isPruned()) return; } }
public void applyDomainRange(final Individual subj, final Role pred, final Node obj, final DependencySet ds) { final Set<ATermAppl> domains = pred.getDomains(); final Set<ATermAppl> ranges = pred.getRanges(); for (final ATermAppl domain : domains) { if (_logger.isLoggable(Level.FINE) && !subj.hasType(domain)) _logger.fine("DOM : " + obj + " <- " + pred + " <- " + subj + " : " + ATermUtils.toString(domain)); addType(subj, domain, ds.union(pred.getExplainDomain(domain), _abox.doExplanation())); if (subj.isPruned() || obj.isPruned()) return; } for (final ATermAppl range : ranges) { if (_logger.isLoggable(Level.FINE) && !obj.hasType(range)) _logger.fine("RAN : " + subj + " -> " + pred + " -> " + obj + " : " + ATermUtils.toString(range)); addType(obj, range, ds.union(pred.getExplainRange(range), _abox.doExplanation())); if (subj.isPruned() || obj.isPruned()) return; } }
protected void apply(final Individual x, final ATermAppl maxCard) { // max(r, n, c) is in normalized form not(min(p, n + 1, c)) final ATermAppl max = (ATermAppl) maxCard.getArgument(0); final Role r = _strategy.getABox().getRole(max.getArgument(0)); final ATermAppl c = (ATermAppl) max.getArgument(2); if (ATermUtils.isTop(c)) return; if (!OpenlletOptions.MAINTAIN_COMPLETION_QUEUE && x.getDepends(maxCard) == null) return; final EdgeList edges = x.getRNeighborEdges(r); for (final Edge edge : edges) { final Node neighbor = edge.getNeighbor(x); if (!neighbor.hasType(c) && !neighbor.hasType(ATermUtils.negate(c))) { final ChooseBranch newBranch = new ChooseBranch(_strategy.getABox(), _strategy, neighbor, c, x.getDepends(maxCard)); _strategy.addBranch(newBranch); newBranch.tryNext(); if (_strategy.getABox().isClosed()) return; } } }
protected void apply(final Individual x, final ATermAppl maxCard) { // max(r, n, c) is in normalized form not(min(p, n + 1, c)) final ATermAppl max = (ATermAppl) maxCard.getArgument(0); final Role r = _strategy.getABox().getRole(max.getArgument(0)); final ATermAppl c = (ATermAppl) max.getArgument(2); if (ATermUtils.isTop(c)) return; if (!OpenlletOptions.MAINTAIN_COMPLETION_QUEUE && x.getDepends(maxCard) == null) return; final EdgeList edges = x.getRNeighborEdges(r); for (final Edge edge : edges) { final Node neighbor = edge.getNeighbor(x); if (!neighbor.hasType(c) && !neighbor.hasType(ATermUtils.negate(c))) { final ChooseBranch newBranch = new ChooseBranch(_strategy.getABox(), _strategy, neighbor, c, x.getDepends(maxCard)); _strategy.addBranch(newBranch); newBranch.tryNext(); if (_strategy.getABox().isClosed()) return; } } }
@Test public void testMerge3() { classes(_person, _man, _dog); objectProperties(_sibling, _owns); individuals(_mary, _chris, _victor, _john, _bill); _kb.addPropertyValue(_sibling, _bill, _mary); _kb.addPropertyValue(_sibling, _bill, _john); _kb.addSubClass(_man, some(_owns, _dog)); assertTrue(_kb.isConsistent()); assertFalse(_kb.getABox().getNode(_mary).isSame(_kb.getABox().getNode(_john))); _kb.addType(_bill, max(_sibling, 1, TOP)); _kb.addType(_mary, or(_man, _dog)); _kb.addType(_chris, or(_man, _dog)); assertTrue(_kb.isConsistent()); assertTrue(_kb.getABox().getNode(_mary).isSame(_kb.getABox().getNode(_john))); _kb.removeType(_bill, max(_sibling, 1, TOP)); assertTrue(_kb.isConsistent()); assertFalse(_kb.getABox().getNode(_mary).isSame(_kb.getABox().getNode(_john))); assertFalse(_kb.getABox().getNode(_john).hasType(_man) || _kb.getABox().getNode(_john).hasType(_dog)); assertTrue(_kb.getABox().getNode(_mary).hasType(_man) || _kb.getABox().getNode(_mary).hasType(_dog)); }