Search in sources :

Example 41 with Predicate

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

the class OWLPropertyExpressionVisitorImpl method visit.

@Override
public InMemoryAtomSet visit(OWLObjectInverseOf property) {
    Predicate p = GraalUtils.createPredicate(property.getInverse());
    Atom a = DefaultAtomFactory.instance().create(p, glueVariable2, glueVariable1);
    return GraalUtils.createAtomSet(a);
}
Also used : Atom(fr.lirmm.graphik.graal.api.core.Atom) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Example 42 with Predicate

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

the class OWLPropertyExpressionVisitorImpl method visit.

@Override
public InMemoryAtomSet visit(OWLDataProperty property) {
    Predicate p = GraalUtils.createPredicate(property);
    Atom a = DefaultAtomFactory.instance().create(p, glueVariable1, glueVariable2);
    return GraalUtils.createAtomSet(a);
}
Also used : Atom(fr.lirmm.graphik.graal.api.core.Atom) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Example 43 with Predicate

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

the class NoTripleStoreTest method arityTest.

@Theory
public void arityTest(AtomSet store) throws AtomSetException, IteratorException, ParseException {
    Assume.assumeFalse(store instanceof TripleStore);
    Atom toAdd = DlgpParser.parseAtom("<P>(a).");
    Predicate toCheck = new Predicate("P", 2);
    store.add(toAdd);
    CloseableIterator<?> it = store.termsByPredicatePosition(toCheck, 1);
    Assert.assertFalse(it.hasNext());
    it = store.atomsByPredicate(toCheck);
    Assert.assertFalse(it.hasNext());
    it = store.match(DlgpParser.parseAtom("<p>(X,Y)."));
    Assert.assertFalse(it.hasNext());
}
Also used : TripleStore(fr.lirmm.graphik.graal.api.store.TripleStore) Atom(fr.lirmm.graphik.graal.api.core.Atom) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) Theory(org.junit.experimental.theories.Theory)

Example 44 with Predicate

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

the class NaturalRDBMSStore method termsIterator.

@Override
@Deprecated
public CloseableIterator<Term> termsIterator(Type type) throws AtomSetException {
    Set<Term> terms = new TreeSet<Term>();
    CloseableIterator<Predicate> predIt = this.predicatesIterator();
    try {
        while (predIt.hasNext()) {
            Predicate p = predIt.next();
            for (int i = 0; i < p.getArity(); ++i) {
                CloseableIterator<Term> termIt = this.termsByPredicatePosition(p, i);
                while (termIt.hasNext()) {
                    Term t = termIt.next();
                    if (type.equals(t.getType())) {
                        terms.add(t);
                    }
                }
            }
        }
    } catch (IteratorException e) {
        throw new AtomSetException(e);
    }
    return new CloseableIteratorAdapter<Term>(terms.iterator());
}
Also used : IteratorException(fr.lirmm.graphik.util.stream.IteratorException) TreeSet(java.util.TreeSet) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) Term(fr.lirmm.graphik.graal.api.core.Term) CloseableIteratorAdapter(fr.lirmm.graphik.util.stream.CloseableIteratorAdapter) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Example 45 with Predicate

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

the class NaturalRDBMSStore method termsIterator.

@Override
public CloseableIterator<Term> termsIterator() throws AtomSetException {
    Set<Term> terms = new TreeSet<Term>();
    CloseableIterator<Predicate> predIt = this.predicatesIterator();
    try {
        while (predIt.hasNext()) {
            Predicate p = predIt.next();
            for (int i = 0; i < p.getArity(); ++i) {
                CloseableIterator<Term> termIt = this.termsByPredicatePosition(p, i);
                while (termIt.hasNext()) {
                    terms.add(termIt.next());
                }
            }
        }
    } catch (IteratorException e) {
        throw new AtomSetException(e);
    }
    return new CloseableIteratorAdapter<Term>(terms.iterator());
}
Also used : IteratorException(fr.lirmm.graphik.util.stream.IteratorException) TreeSet(java.util.TreeSet) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) Term(fr.lirmm.graphik.graal.api.core.Term) CloseableIteratorAdapter(fr.lirmm.graphik.util.stream.CloseableIteratorAdapter) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Aggregations

Predicate (fr.lirmm.graphik.graal.api.core.Predicate)77 Atom (fr.lirmm.graphik.graal.api.core.Atom)35 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)28 Term (fr.lirmm.graphik.graal.api.core.Term)27 Test (org.junit.Test)25 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)16 LinkedList (java.util.LinkedList)16 Theory (org.junit.experimental.theories.Theory)14 AtomSetException (fr.lirmm.graphik.graal.api.core.AtomSetException)9 Rule (fr.lirmm.graphik.graal.api.core.Rule)9 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)9 LinkedListRuleSet (fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet)7 DefaultURI (fr.lirmm.graphik.util.DefaultURI)7 TreeSet (java.util.TreeSet)7 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)6 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)6 RuleSet (fr.lirmm.graphik.graal.api.core.RuleSet)6 Variable (fr.lirmm.graphik.graal.api.core.Variable)6 ConversionException (fr.lirmm.graphik.util.stream.converter.ConversionException)6 Pair (org.apache.commons.lang3.tuple.Pair)6