Search in sources :

Example 11 with DefaultConjunctiveQuery

use of fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery in project graal by graphik-team.

the class LiteralsTest method booleanType.

@Theory
public void booleanType(AtomSet store) throws Exception {
    Atom a = DlgpParser.parseAtom("<IS_HUMAN>(a,true).");
    store.add(a);
    ConjunctiveQuery q = new DefaultConjunctiveQuery(new LinkedListAtomSet(a), Collections.<Term>emptyList());
    Assert.assertTrue(SmartHomomorphism.instance().execute(q, store).hasNext());
    Atom b = store.iterator().next();
    Assert.assertEquals(a, b);
}
Also used : DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) Atom(fr.lirmm.graphik.graal.api.core.Atom) ConjunctiveQuery(fr.lirmm.graphik.graal.api.core.ConjunctiveQuery) DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) Theory(org.junit.experimental.theories.Theory)

Example 12 with DefaultConjunctiveQuery

use of fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery in project graal by graphik-team.

the class LiteralsTest method stringType.

@Theory
public void stringType(AtomSet store) throws Exception {
    Atom a = DlgpParser.parseAtom("<NAME>(a,\"john\").");
    store.add(a);
    ConjunctiveQuery q = new DefaultConjunctiveQuery(new LinkedListAtomSet(a), Collections.<Term>emptyList());
    Assert.assertTrue(SmartHomomorphism.instance().execute(q, store).hasNext());
    Atom b = store.iterator().next();
    Assert.assertEquals(a, b);
}
Also used : DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) Atom(fr.lirmm.graphik.graal.api.core.Atom) ConjunctiveQuery(fr.lirmm.graphik.graal.api.core.ConjunctiveQuery) DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) Theory(org.junit.experimental.theories.Theory)

Example 13 with DefaultConjunctiveQuery

use of fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery in project graal by graphik-team.

the class LiteralsTest method decimalType.

@Theory
public void decimalType(AtomSet store) throws Exception {
    Atom a = DlgpParser.parseAtom("<AGE>(a,-5.1).");
    store.add(a);
    ConjunctiveQuery q = new DefaultConjunctiveQuery(new LinkedListAtomSet(a), Collections.<Term>emptyList());
    Assert.assertTrue(SmartHomomorphism.instance().execute(q, store).hasNext());
    Atom b = store.iterator().next();
    Assert.assertEquals(a, b);
}
Also used : DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) Atom(fr.lirmm.graphik.graal.api.core.Atom) ConjunctiveQuery(fr.lirmm.graphik.graal.api.core.ConjunctiveQuery) DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) Theory(org.junit.experimental.theories.Theory)

Example 14 with DefaultConjunctiveQuery

use of fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery in project graal by graphik-team.

the class ConjunctiveQueryFixedBugTest method GraphAtomSetQuery.

/**
 * Query using an DefaultInMemoryGraphAtomSet.
 *
 * @param h
 * @param store
 */
@Theory
public void GraphAtomSetQuery(Homomorphism<ConjunctiveQuery, AtomSet> h, AtomSet store) {
    try {
        InMemoryAtomSet atomset = new DefaultInMemoryGraphStore();
        atomset.add(DlgpParser.parseAtom("<P>(X)."));
        ConjunctiveQuery query = new DefaultConjunctiveQuery(atomset);
        CloseableIterator<Substitution> subReader;
        subReader = h.execute(query, store);
        Assert.assertFalse(subReader.hasNext());
        subReader.close();
    } catch (Exception e) {
        Assert.assertTrue(e.getMessage(), false);
    }
}
Also used : DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) Substitution(fr.lirmm.graphik.graal.api.core.Substitution) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) DefaultInMemoryGraphStore(fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore) ConjunctiveQuery(fr.lirmm.graphik.graal.api.core.ConjunctiveQuery) DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) HomomorphismException(fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) IteratorException(fr.lirmm.graphik.util.stream.IteratorException) Theory(org.junit.experimental.theories.Theory)

Example 15 with DefaultConjunctiveQuery

use of fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery in project graal by graphik-team.

the class ConjunctiveQueryWithCompilation method issue35.

@Theory
public void issue35(Homomorphism<ConjunctiveQuery, AtomSet> hh, RulesCompilationFactory factory, AtomSet store) throws Exception {
    Assume.assumeFalse(store instanceof TripleStore);
    Assume.assumeTrue(hh instanceof HomomorphismWithCompilation);
    HomomorphismWithCompilation<ConjunctiveQuery, AtomSet> h = (HomomorphismWithCompilation<ConjunctiveQuery, AtomSet>) hh;
    store.addAll(DlgpParser.parseAtomSet("<P>(a,a), <R>(a,b,b)."));
    RuleSet rules = new LinkedListRuleSet();
    rules.add(DlgpParser.parseRule("<Q>(X,Y,X) :- <P>(X,Y)."));
    ConjunctiveQuery query = DlgpParser.parseQuery("? :- <Q>(X,Y,Y), <R>(X,Y,Z).");
    RulesCompilation comp = factory.create();
    comp.compile(rules.iterator());
    StaticChase.executeChase(store, rules);
    CloseableIterator<Substitution> results = h.execute(new DefaultConjunctiveQuery(query), store, comp);
    Assert.assertFalse(results.hasNext());
    results.close();
}
Also used : RuleSet(fr.lirmm.graphik.graal.api.core.RuleSet) LinkedListRuleSet(fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet) DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) Substitution(fr.lirmm.graphik.graal.api.core.Substitution) TripleStore(fr.lirmm.graphik.graal.api.store.TripleStore) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) AtomSet(fr.lirmm.graphik.graal.api.core.AtomSet) LinkedListRuleSet(fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet) RulesCompilation(fr.lirmm.graphik.graal.api.core.RulesCompilation) ConjunctiveQuery(fr.lirmm.graphik.graal.api.core.ConjunctiveQuery) DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) HomomorphismWithCompilation(fr.lirmm.graphik.graal.api.homomorphism.HomomorphismWithCompilation) Theory(org.junit.experimental.theories.Theory)

Aggregations

DefaultConjunctiveQuery (fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery)15 LinkedListAtomSet (fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet)11 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)10 Theory (org.junit.experimental.theories.Theory)9 Atom (fr.lirmm.graphik.graal.api.core.Atom)8 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)6 AtomSet (fr.lirmm.graphik.graal.api.core.AtomSet)5 RuleSet (fr.lirmm.graphik.graal.api.core.RuleSet)5 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)5 LinkedListRuleSet (fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet)5 HomomorphismException (fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException)4 RulesCompilation (fr.lirmm.graphik.graal.api.core.RulesCompilation)3 ChaseException (fr.lirmm.graphik.graal.api.forward_chaining.ChaseException)3 LinkedList (java.util.LinkedList)3 HomomorphismWithCompilation (fr.lirmm.graphik.graal.api.homomorphism.HomomorphismWithCompilation)2 TripleStore (fr.lirmm.graphik.graal.api.store.TripleStore)2 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)2 DefaultInMemoryGraphStore (fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore)2 AnalyserRuleSet (fr.lirmm.graphik.graal.rulesetanalyser.util.AnalyserRuleSet)2 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)2