Search in sources :

Example 1 with Atom

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;
}
Also used : DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Atom(fr.lirmm.graphik.graal.api.core.Atom)

Example 2 with Atom

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);
    }
}
Also used : DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Atom(fr.lirmm.graphik.graal.api.core.Atom)

Example 3 with Atom

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;
}
Also used : Atom(fr.lirmm.graphik.graal.api.core.Atom) LinkedList(java.util.LinkedList)

Example 4 with Atom

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;
}
Also used : DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) Term(fr.lirmm.graphik.graal.api.core.Term) LinkedList(java.util.LinkedList) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Atom(fr.lirmm.graphik.graal.api.core.Atom) OWLIndividual(org.semanticweb.owlapi.model.OWLIndividual)

Example 5 with Atom

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));
}
Also used : Term(fr.lirmm.graphik.graal.api.core.Term) ConjunctiveQuery(fr.lirmm.graphik.graal.api.core.ConjunctiveQuery) Atom(fr.lirmm.graphik.graal.api.core.Atom) Test(org.junit.Test)

Aggregations

Atom (fr.lirmm.graphik.graal.api.core.Atom)269 Test (org.junit.Test)97 Term (fr.lirmm.graphik.graal.api.core.Term)86 Rule (fr.lirmm.graphik.graal.api.core.Rule)64 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)41 OWL2Parser (fr.lirmm.graphik.graal.io.owl.OWL2Parser)41 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)40 LinkedList (java.util.LinkedList)40 DefaultNegativeConstraint (fr.lirmm.graphik.graal.core.DefaultNegativeConstraint)36 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)35 Theory (org.junit.experimental.theories.Theory)35 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)34 Variable (fr.lirmm.graphik.graal.api.core.Variable)33 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)31 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)29 LinkedListAtomSet (fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet)28 AtomSetException (fr.lirmm.graphik.graal.api.core.AtomSetException)27 HomomorphismException (fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException)14 CloseableIteratorWithoutException (fr.lirmm.graphik.util.stream.CloseableIteratorWithoutException)14 OWL2ParserException (fr.lirmm.graphik.graal.io.owl.OWL2ParserException)13