Search in sources :

Example 1 with DefaultConjunctiveQuery

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

the class DefaultConjunctiveQueryFactory method create.

@Override
public ConjunctiveQuery create(Atom atom, List<Term> ans) {
    LinkedList<Atom> list = new LinkedList<Atom>();
    list.add(atom);
    return new DefaultConjunctiveQuery(new LinkedListAtomSet(list), ans);
}
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) LinkedList(java.util.LinkedList)

Example 2 with DefaultConjunctiveQuery

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

the class ConjunctiveQueryWithCompilation method issueWithAtom2SubstitutionConverter.

@Theory
public void issueWithAtom2SubstitutionConverter(RulesCompilationFactory factory, AtomSet store) throws Exception {
    Assume.assumeFalse(store instanceof TripleStore);
    HomomorphismWithCompilation<ConjunctiveQuery, AtomSet> h = AtomicQueryHomomorphism.instance();
    store.addAll(DlgpParser.parseAtomSet("<P>(a,a)."));
    RuleSet rules = new LinkedListRuleSet();
    rules.add(DlgpParser.parseRule("<Q>(X,Y,X) :- <P>(X,Y)."));
    RulesCompilation comp = factory.create();
    comp.compile(rules.iterator());
    StaticChase.executeChase(store, rules);
    ConjunctiveQuery query = DlgpParser.parseQuery("?(X) :- <Q>(X,Y,Y).");
    CloseableIterator<Substitution> results = h.execute(new DefaultConjunctiveQuery(query), store, comp);
    Assert.assertTrue(results.hasNext());
    results.close();
    query = DlgpParser.parseQuery("?(Y) :- <Q>(X,Y,Y).");
    results = h.execute(new DefaultConjunctiveQuery(query), store, comp);
    Assert.assertTrue(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) Theory(org.junit.experimental.theories.Theory)

Example 3 with DefaultConjunctiveQuery

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

the class LiteralsTest method integerType.

@Theory
public void integerType(AtomSet store) throws Exception {
    Atom a = DlgpParser.parseAtom("<AGE>(a,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 4 with DefaultConjunctiveQuery

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

the class DefaultConjunctiveQueryFactory method create.

@Override
public ConjunctiveQuery create(Atom atom) {
    LinkedList<Atom> list = new LinkedList<Atom>();
    list.add(atom);
    return new DefaultConjunctiveQuery(new LinkedListAtomSet(list));
}
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) LinkedList(java.util.LinkedList)

Example 5 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)

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