Search in sources :

Example 36 with Predicate

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

the class IDCompilation method computeSaturation.

private void computeSaturation() {
    // deep copy of conditions
    Map<Predicate, TreeMap<Predicate, LinkedList<IDCondition>>> conditionsTmp = deepCopyMapMapList(this.conditions);
    // p -> q
    Predicate p, q;
    for (Map.Entry<Predicate, TreeMap<Predicate, LinkedList<IDCondition>>> e : conditionsTmp.entrySet()) {
        q = e.getKey();
        for (Map.Entry<Predicate, LinkedList<IDCondition>> map : e.getValue().entrySet()) {
            p = map.getKey();
            for (IDCondition conditionPQ : map.getValue()) {
                computeSaturation(conditionsTmp, p, q, conditionPQ);
            }
        }
    }
}
Also used : TreeMap(java.util.TreeMap) Map(java.util.Map) TreeMap(java.util.TreeMap) LinkedList(java.util.LinkedList) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Example 37 with Predicate

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

the class DefaultOntology method resetVocabulary.

// /////////////////////////////////////////////////////////////////////////
// OBJECT OVERRIDE METHODS
// /////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
// PRIVATE METHODS
// /////////////////////////////////////////////////////////////////////////
/**
 */
private void resetVocabulary() {
    // reset vocabulary
    this.vocabulary = new TreeSet<Predicate>();
    for (Rule r : this) {
        this.vocabulary.addAll(r.getBody().getPredicates());
        this.vocabulary.addAll(r.getHead().getPredicates());
    }
}
Also used : Rule(fr.lirmm.graphik.graal.api.core.Rule) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Example 38 with Predicate

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

the class AdHocRdbmsStore method clear.

@Override
public void clear() throws AtomSetException {
    try {
        Statement stat = null;
        CloseableIterator<Predicate> it = this.predicatesIterator();
        try {
            stat = this.createStatement();
            while (it.hasNext()) {
                Predicate p = it.next();
                this.removePredicate(stat, p);
            }
            stat.execute(String.format(TRUNCATE_TABLE, PREDICATE_TABLE_NAME));
            stat.execute(String.format(TRUNCATE_TABLE, TERMS_TABLE));
            stat.close();
            this.getConnection().commit();
        } catch (IteratorException e) {
            this.getConnection().rollback();
            throw new AtomSetException(e);
        } catch (SQLException e) {
            this.getConnection().rollback();
            throw new AtomSetException(e);
        } finally {
            if (stat != null)
                stat.close();
        }
    } catch (SQLException e) {
        throw new AtomSetException(e);
    }
}
Also used : IteratorException(fr.lirmm.graphik.util.stream.IteratorException) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Example 39 with Predicate

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

the class MarkedVariableSet method firstStep.

/**
 * for each rule Ri and for each variable v occuring in its body, if v does
 * not occur in all atoms of its head, mark (each occurrence of) v in its
 * body;
 */
private void firstStep() {
    for (MarkedRule markedRule : this.markedRuleSet) {
        // put rule in the map
        CloseableIteratorWithoutException<Atom> it = markedRule.rule.getHead().iterator();
        while (it.hasNext()) {
            Atom atom = it.next();
            Predicate p = atom.getPredicate();
            LinkedList<MarkedRule> set = map.get(p);
            if (set == null) {
                set = new LinkedList<MarkedRule>();
                map.put(p, set);
            }
            set.add(markedRule);
        }
        // mark the rule
        testRule(markedRule);
    }
}
Also used : Atom(fr.lirmm.graphik.graal.api.core.Atom) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Example 40 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(OWLObjectProperty 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)

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