/** * {@inheritDoc} */ @Override protected void addRoleHierarchyRule(final ATermAppl sub, final ATermAppl sup) { addRoleChainRule(new ATerm[] { sub }, sup); }
/** * {@inheritDoc} */ @Override protected void addSubclassRule(final ATermAppl sub, final ATermAppl sup) { addSubclassRule(sub, sup, new FreeVariableStore()); }
private void makeRuleAxioms() { makeBottomAxiom(); }
private void makeBottomAxiom() { final FreeVariableStore freeVar = new FreeVariableStore(); final Node var0 = freeVar.next(); final Node var1 = freeVar.next(); final Node var2 = freeVar.next(); final List<ClauseEntry> body = new ArrayList<>(); body.add(makeSubOfSomeTriple(var0, var1, var2)); body.add(makePropertyAssertionFunctor(var1)); body.add(makeSubclassTriple(var2, BOTTOM)); final ClauseEntry head = makeSubclassTriple(var0, BOTTOM); _rules.add(new Rule(Collections.singletonList(head), body)); }
outHead.add(makeSubclassTriple(currentVar, _names.get(sup))); else if (fun.equals(ATermUtils.ANDFUN)) translateSuper(outHead, conj, freeVar, currentVar); list = list.getNext(); translateSuperSome(anon, q); q = anon; outHead.add(makeSubOfSomeTriple(currentVar, prop, _names.get(q)));
private void translateSub(final List<ClauseEntry> outBody, final ATermAppl sub, final FreeVariableStore freeVar, final Node currentVar) { final AFun fun = sub.getAFun(); if (ATermUtils.isPrimitive(sub) || ATermUtils.isBottom(sub)) outBody.add(makeSubclassTriple(currentVar, _names.get(sub))); else if (fun.equals(ATermUtils.ANDFUN)) { ATermList list = (ATermList) sub.getArgument(0); while (!list.isEmpty()) { final ATermAppl conj = (ATermAppl) list.getFirst(); translateSub(outBody, conj, freeVar, currentVar); list = list.getNext(); } } else if (fun.equals(ATermUtils.SOMEFUN)) { final ATermAppl prop = (ATermAppl) sub.getArgument(0); final ATermAppl q = (ATermAppl) sub.getArgument(1); final Node nextVar = freeVar.next(); outBody.add(makeSubOfSomeTriple(currentVar, prop, nextVar)); translateSub(outBody, q, freeVar, nextVar); } else assert false; }
_facts.add(makeSubclassFact(anon, sup)); else if (fun.equals(ATermUtils.ANDFUN)) translateSuperSome(anon, conj); list = list.getNext(); translateSuperSome(nextAnon, q); q = nextAnon; _facts.add(makeSubOfSomeFact(anon, prop, q));
/** * {@inheritDoc} */ @Override protected void addRoleDomainRule(final ATermAppl p, final ATermAppl domain) { final List<ClauseEntry> body = new ArrayList<>(); final List<ClauseEntry> head = new ArrayList<>(); final FreeVariableStore freeVar = new FreeVariableStore(); final Node var0 = freeVar.next(); final Node var1 = freeVar.next(); body.add(makeSubOfSomeTriple(var0, p, var1)); translateSuper(head, domain, freeVar, var0); _rules.add(new Rule(head, body)); }
@Override protected MultiValueMap<ATermAppl, ATermAppl> run(final Collection<ATermAppl> classes) { addClasses(classes); addClasses(_names.getAllAnons()); final Reasoner reasoner = new GenericRuleReasoner(new ArrayList<>(_rules)); final InfGraph inf = reasoner.bind(_facts); inf.prepare(); final MultiValueMap<ATermAppl, ATermAppl> subsumers = getSubsumptions(inf); for (final ATermAppl c : classes) subsumers.add(ATermUtils.BOTTOM, c); return subsumers; }
private TriplePattern makeSubOfSomeTriple(final Node t1, final ATermAppl p, final Node t2) { return makeSubOfSomeTriple(t1, _names.get(p), t2); }
public JenaBasedELClassifier(final KnowledgeBase kb) { super(kb); _names = new NameStore(); _variables = new VariableStore(); _facts = GraphFactory.createDefaultGraph(); TOP = _names.get(ATermUtils.TOP); BOTTOM = _names.get(ATermUtils.BOTTOM); makeRuleAxioms(); }
private Triple makeSubclassFact(final ATermAppl t1, final ATermAppl t2) { return makeSubclassFact(_names.get(t1), _names.get(t2)); }
outHead.add(makeSubclassTriple(currentVar, _names.get(sup))); else if (fun.equals(ATermUtils.ANDFUN)) translateSuper(outHead, conj, freeVar, currentVar); list = list.getNext(); translateSuperSome(anon, q); q = anon; outHead.add(makeSubOfSomeTriple(currentVar, prop, _names.get(q)));
private void makeBottomAxiom() { final FreeVariableStore freeVar = new FreeVariableStore(); final Node var0 = freeVar.next(); final Node var1 = freeVar.next(); final Node var2 = freeVar.next(); final List<ClauseEntry> body = new ArrayList<>(); body.add(makeSubOfSomeTriple(var0, var1, var2)); body.add(makePropertyAssertionFunctor(var1)); body.add(makeSubclassTriple(var2, BOTTOM)); final ClauseEntry head = makeSubclassTriple(var0, BOTTOM); _rules.add(new Rule(Collections.singletonList(head), body)); }
private void translateSub(final List<ClauseEntry> outBody, final ATermAppl sub, final FreeVariableStore freeVar, final Node currentVar) { final AFun fun = sub.getAFun(); if (ATermUtils.isPrimitive(sub) || ATermUtils.isBottom(sub)) outBody.add(makeSubclassTriple(currentVar, _names.get(sub))); else if (fun.equals(ATermUtils.ANDFUN)) { ATermList list = (ATermList) sub.getArgument(0); while (!list.isEmpty()) { final ATermAppl conj = (ATermAppl) list.getFirst(); translateSub(outBody, conj, freeVar, currentVar); list = list.getNext(); } } else if (fun.equals(ATermUtils.SOMEFUN)) { final ATermAppl prop = (ATermAppl) sub.getArgument(0); final ATermAppl q = (ATermAppl) sub.getArgument(1); final Node nextVar = freeVar.next(); outBody.add(makeSubOfSomeTriple(currentVar, prop, nextVar)); translateSub(outBody, q, freeVar, nextVar); } else assert false; }
_facts.add(makeSubclassFact(anon, sup)); else if (fun.equals(ATermUtils.ANDFUN)) translateSuperSome(anon, conj); list = list.getNext(); translateSuperSome(nextAnon, q); q = nextAnon; _facts.add(makeSubOfSomeFact(anon, prop, q));
/** * {@inheritDoc} */ @Override protected void addRoleDomainRule(final ATermAppl p, final ATermAppl domain) { final List<ClauseEntry> body = new ArrayList<>(); final List<ClauseEntry> head = new ArrayList<>(); final FreeVariableStore freeVar = new FreeVariableStore(); final Node var0 = freeVar.next(); final Node var1 = freeVar.next(); body.add(makeSubOfSomeTriple(var0, p, var1)); translateSuper(head, domain, freeVar, var0); _rules.add(new Rule(head, body)); }
@Override protected MultiValueMap<ATermAppl, ATermAppl> run(final Collection<ATermAppl> classes) { addClasses(classes); addClasses(_names.getAllAnons()); final Reasoner reasoner = new GenericRuleReasoner(new ArrayList<>(_rules)); final InfGraph inf = reasoner.bind(_facts); inf.prepare(); final MultiValueMap<ATermAppl, ATermAppl> subsumers = getSubsumptions(inf); for (final ATermAppl c : classes) subsumers.add(ATermUtils.BOTTOM, c); return subsumers; }
private TriplePattern makeSubOfSomeTriple(final Node t1, final ATermAppl p, final Node t2) { return makeSubOfSomeTriple(t1, _names.get(p), t2); }
public JenaBasedELClassifier(final KnowledgeBase kb) { super(kb); _names = new NameStore(); _variables = new VariableStore(); _facts = GraphFactory.createDefaultGraph(); TOP = _names.get(ATermUtils.TOP); BOTTOM = _names.get(ATermUtils.BOTTOM); makeRuleAxioms(); }