public void reset() { _query = new QueryImpl(_reasoner.getKB(), false); }
/** * {@inheritDoc} */ @Override public List<QueryAtom> findAtoms(final QueryPredicate predicate, final ATermAppl... args) { return _findAtoms(Collections.<ATermAppl> emptySet(), predicate, args); }
/** * {@inheritDoc} */ @Override public Query apply(final ResultBinding binding) { final List<QueryAtom> atoms = new ArrayList<>(); for (final QueryAtom atom : getAtoms()) atoms.add(atom.apply(binding)); final QueryImpl query = new QueryImpl(this); query._resultVars.addAll(_resultVars); query._resultVars.removeAll(binding.getAllVariables()); for (final VarType type : VarType.values()) for (final ATermAppl atom : getDistVarsForType(type)) if (!binding.isBound(atom)) query.addDistVar(atom, type); for (final QueryAtom atom : atoms) query.add(atom); return query; }
/** * {@inheritDoc} TODO */ @Override public ATermAppl rollUpTo(final ATermAppl var, final Collection<ATermAppl> stopList, final boolean stopOnConstants) { if (getDistVarsForType(VarType.LITERAL).contains(var) && !getDistVarsForType(VarType.INDIVIDUAL).contains(var) && !_individualsAndLiterals.contains(var)) throw new InternalReasonerException("Trying to roll up to the variable '" + var + "' which is not distinguished and _individual."); ATermList classParts = ATermUtils.EMPTY_LIST; final Set<ATermAppl> visited = new HashSet<>(); if (stopOnConstants) visited.addAll(getConstants()); final Collection<QueryAtom> inEdges = findAtoms(QueryPredicate.PropertyValue, null, null, var); for (final QueryAtom a : inEdges) classParts = classParts.append(rollEdgeIn(QueryPredicate.PropertyValue, a, visited, stopList)); final Collection<QueryAtom> outEdges = findAtoms(QueryPredicate.PropertyValue, var, null, null); for (final QueryAtom a : outEdges) classParts = classParts.append(rollEdgeOut(QueryPredicate.PropertyValue, a, visited, stopList)); classParts = classParts.concat(getClasses(var)); return ATermUtils.makeAnd(classParts); }
final ATermList temp = getClasses(subj); if (temp.getLength() == 0) ATermList targetClasses = getClasses(subj); final List<QueryAtom> targetIns = _findAtoms(stopList, allowed, null, null, subj); for (final QueryAtom o : _findAtoms(stopList, allowed, subj, null, null)) if (!o.equals(atom)) targetClasses = targetClasses.append(rollEdgeOut(allowed, o, visited, stopList)); ins = ins.append(rollEdgeIn(allowed, currEdge, visited, stopList)); ins = ins.append(rollEdgeIn(allowed, currEdge, visited, stopList));
/** * {@inheritDoc} */ @Override public Set<ATermAppl> getUndistVars() { final Set<ATermAppl> result = new HashSet<>(_allVars); result.removeAll(getDistVars()); return result; }
private ATermList getClasses(final ATermAppl a) { final List<ATermAppl> aterms = new ArrayList<>(); for (final QueryAtom atom : findAtoms(QueryPredicate.Type, a, null)) { final ATermAppl arg = atom.getArguments().get(1); if (ATermUtils.isVar(arg)) throw new InternalReasonerException("Variables as predicates are not supported yet"); aterms.add(arg); } if (!ATermUtils.isVar(a)) aterms.add(ATermUtils.makeValue(a)); return ATermUtils.makeList(aterms); }
/** * {@inheritDoc} TODO */ @Override public ATermAppl rollUpTo(final ATermAppl var, final Collection<ATermAppl> stopList, final boolean stopOnConstants) { if (getDistVarsForType(VarType.LITERAL).contains(var) && !getDistVarsForType(VarType.INDIVIDUAL).contains(var) && !_individualsAndLiterals.contains(var)) throw new InternalReasonerException("Trying to roll up to the variable '" + var + "' which is not distinguished and _individual."); ATermList classParts = ATermUtils.EMPTY_LIST; final Set<ATermAppl> visited = new HashSet<>(); if (stopOnConstants) visited.addAll(getConstants()); final Collection<QueryAtom> inEdges = findAtoms(QueryPredicate.PropertyValue, null, null, var); for (final QueryAtom a : inEdges) classParts = classParts.append(rollEdgeIn(QueryPredicate.PropertyValue, a, visited, stopList)); final Collection<QueryAtom> outEdges = findAtoms(QueryPredicate.PropertyValue, var, null, null); for (final QueryAtom a : outEdges) classParts = classParts.append(rollEdgeOut(QueryPredicate.PropertyValue, a, visited, stopList)); classParts = classParts.concat(getClasses(var)); return ATermUtils.makeAnd(classParts); }
final ATermList temp = getClasses(subj); if (temp.getLength() == 0) ATermList targetClasses = getClasses(subj); final List<QueryAtom> targetIns = _findAtoms(stopList, allowed, null, null, subj); for (final QueryAtom o : _findAtoms(stopList, allowed, subj, null, null)) if (!o.equals(atom)) targetClasses = targetClasses.append(rollEdgeOut(allowed, o, visited, stopList)); ins = ins.append(rollEdgeIn(allowed, currEdge, visited, stopList)); ins = ins.append(rollEdgeIn(allowed, currEdge, visited, stopList));
/** * {@inheritDoc} */ @Override public Set<ATermAppl> getUndistVars() { final Set<ATermAppl> result = new HashSet<>(_allVars); result.removeAll(getDistVars()); return result; }
private ATermList getClasses(final ATermAppl a) { final List<ATermAppl> aterms = new ArrayList<>(); for (final QueryAtom atom : findAtoms(QueryPredicate.Type, a, null)) { final ATermAppl arg = atom.getArguments().get(1); if (ATermUtils.isVar(arg)) throw new InternalReasonerException("Variables as predicates are not supported yet"); aterms.add(arg); } if (!ATermUtils.isVar(a)) aterms.add(ATermUtils.makeValue(a)); return ATermUtils.makeList(aterms); }
public void reset() { _query = new QueryImpl(_reasoner.getKB(), false); }
/** * {@inheritDoc} */ @Override public Query apply(final ResultBinding binding) { final List<QueryAtom> atoms = new ArrayList<>(); for (final QueryAtom atom : getAtoms()) atoms.add(atom.apply(binding)); final QueryImpl query = new QueryImpl(this); query._resultVars.addAll(_resultVars); query._resultVars.removeAll(binding.getAllVariables()); for (final VarType type : VarType.values()) for (final ATermAppl atom : getDistVarsForType(type)) if (!binding.isBound(atom)) query.addDistVar(atom, type); for (final QueryAtom atom : atoms) query.add(atom); return query; }
/** * {@inheritDoc} TODO */ @Override public ATermAppl rollUpTo(final ATermAppl var, final Collection<ATermAppl> stopList, final boolean stopOnConstants) { if (getDistVarsForType(VarType.LITERAL).contains(var) && !getDistVarsForType(VarType.INDIVIDUAL).contains(var) && !_individualsAndLiterals.contains(var)) throw new InternalReasonerException("Trying to roll up to the variable '" + var + "' which is not distinguished and _individual."); ATermList classParts = ATermUtils.EMPTY_LIST; final Set<ATermAppl> visited = new HashSet<>(); if (stopOnConstants) visited.addAll(getConstants()); final Collection<QueryAtom> inEdges = findAtoms(QueryPredicate.PropertyValue, null, null, var); for (final QueryAtom a : inEdges) classParts = classParts.append(rollEdgeIn(QueryPredicate.PropertyValue, a, visited, stopList)); final Collection<QueryAtom> outEdges = findAtoms(QueryPredicate.PropertyValue, var, null, null); for (final QueryAtom a : outEdges) classParts = classParts.append(rollEdgeOut(QueryPredicate.PropertyValue, a, visited, stopList)); classParts = classParts.concat(getClasses(var)); return ATermUtils.makeAnd(classParts); }
final ATermList temp = getClasses(obj); if (temp.getLength() == 0) ATermList targetClasses = getClasses(obj); for (final QueryAtom in : _findAtoms(stopList, allowed, null, null, obj)) if (!in.equals(atom)) targetClasses = targetClasses.append(rollEdgeIn(allowed, in, visited, stopList)); final List<QueryAtom> targetOuts = _findAtoms(stopList, allowed, obj, null, null); outs = outs.append(rollEdgeOut(allowed, currEdge, visited, stopList)); outs = outs.append(rollEdgeOut(allowed, currEdge, visited, stopList));
/** * {@inheritDoc} */ @Override public List<QueryAtom> findAtoms(final QueryPredicate predicate, final ATermAppl... args) { return _findAtoms(Collections.<ATermAppl> emptySet(), predicate, args); }
/** * {@inheritDoc} */ @Override public Set<ATermAppl> getUndistVars() { final Set<ATermAppl> result = new HashSet<>(_allVars); result.removeAll(getDistVars()); return result; }
private ATermList getClasses(final ATermAppl a) { final List<ATermAppl> aterms = new ArrayList<>(); for (final QueryAtom atom : findAtoms(QueryPredicate.Type, a, null)) { final ATermAppl arg = atom.getArguments().get(1); if (ATermUtils.isVar(arg)) throw new InternalReasonerException("Variables as predicates are not supported yet"); aterms.add(arg); } if (!ATermUtils.isVar(a)) aterms.add(ATermUtils.makeValue(a)); return ATermUtils.makeList(aterms); }
public void reset() { _query = new QueryImpl(_reasoner.getKB(), false); }
/** * {@inheritDoc} */ @Override public Query apply(final ResultBinding binding) { final List<QueryAtom> atoms = new ArrayList<>(); for (final QueryAtom atom : getAtoms()) atoms.add(atom.apply(binding)); final QueryImpl query = new QueryImpl(this); query._resultVars.addAll(_resultVars); query._resultVars.removeAll(binding.getAllVariables()); for (final VarType type : VarType.values()) for (final ATermAppl atom : getDistVarsForType(type)) if (!binding.isBound(atom)) query.addDistVar(atom, type); for (final QueryAtom atom : atoms) query.add(atom); return query; }