use of fr.lirmm.graphik.graal.api.core.Atom in project graal by graphik-team.
the class MarkedQuery method toString.
@Override
public String toString() {
String s = "(MQ| ";
CloseableIteratorWithoutException<Atom> it = this.iterator();
while (it.hasNext()) {
Atom a = it.next();
if (isMarked(a))
s += "*";
s += a.toString() + " ";
}
s += ")";
return s;
}
use of fr.lirmm.graphik.graal.api.core.Atom in project graal by graphik-team.
the class MarkedQuery method markAll.
/**
* mark all the atom of the fact
*/
public void markAll() {
markedAtoms = new ArrayList<Atom>();
CloseableIteratorWithoutException<Atom> it = this.getAtomSet().iterator();
while (it.hasNext()) {
Atom a = it.next();
markedAtoms.add(a);
}
}
use of fr.lirmm.graphik.graal.api.core.Atom in project graal by graphik-team.
the class AggregAllRulesOperator method getUnifiableAtoms.
/**
* Returns the list of the atoms of the query that can be unify with the
* head of R
*
* @param query
* the query to unify
* @param rule
* the rule whose has the head to unify
* @return the list of the atoms of the query that have the same predicate
* as the head atom of R and that are recently created in query
*/
public LinkedList<Atom> getUnifiableAtoms(MarkedQuery query, Rule rule, RulesCompilation compilation) {
LinkedList<Atom> atoms = UnifierUtils.getUnifiableAtoms((ConjunctiveQuery) query, rule, compilation);
LinkedList<Atom> res = new LinkedList<Atom>();
// keep only the recently created so marked in query
for (Atom a : atoms) {
if (query.isMarked(a)) {
res.add(a);
}
}
return res;
}
use of fr.lirmm.graphik.graal.api.core.Atom in project graal by graphik-team.
the class OWLAxiomParser method visit.
@Override
public Iterable<? extends Object> visit(OWLDifferentIndividualsAxiom arg) {
Collection<Object> c = GraalUtils.<Object>createCollection();
LinkedList<OWLIndividual> list = new LinkedList<OWLIndividual>(arg.getIndividualsAsList());
Iterator<OWLIndividual> it1, it2;
it1 = list.iterator();
while (it1.hasNext()) {
OWLIndividual individu1 = it1.next();
it1.remove();
Term t1 = GraalUtils.createTerm(individu1);
it2 = list.iterator();
while (it2.hasNext()) {
OWLIndividual individu2 = it2.next();
Term t2 = GraalUtils.createTerm(individu2);
Atom a = new DefaultAtom(equalityPredicate, t1, t2);
c.add(new DefaultNegativeConstraint(new LinkedListAtomSet(a)));
}
}
return c;
}
use of fr.lirmm.graphik.graal.api.core.Atom in project graal by graphik-team.
the class DlgpParserTest method parseQueryWithBooleanLiteralInAns.
@Test
public void parseQueryWithBooleanLiteralInAns() throws ParseException {
ConjunctiveQuery q = DlgpParser.parseQuery("?(true,X) :- p(a,X).");
List<Term> ans = q.getAnswerVariables();
Assert.assertEquals(LTRUE, ans.get(0));
Assert.assertEquals(X, ans.get(1));
Atom a = q.getAtomSet().iterator().next();
Assert.assertEquals(A, a.getTerm(0));
Assert.assertEquals(X, a.getTerm(1));
}
Aggregations