Search in sources :

Example 71 with Predicate

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

the class IDCompilation method isImplied.

@Override
public boolean isImplied(Atom father, Atom son) {
    Predicate predB = son.getPredicate();
    Predicate predH = father.getPredicate();
    List<IDCondition> conds = getConditions(predB, predH);
    for (IDCondition cond : conds) {
        if (cond.imply(son.getTerms(), father.getTerms())) {
            return true;
        }
    }
    return false;
}
Also used : Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Example 72 with Predicate

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

the class LinkedListAtomSet method getPredicates.

// /////////////////////////////////////////////////////////////////////////
// PUBLIC METHODS
// /////////////////////////////////////////////////////////////////////////
@Override
public Set<Predicate> getPredicates() {
    Set<Predicate> predicates = new HashSet<Predicate>();
    CloseableIteratorWithoutException<Atom> it = this.iterator();
    while (it.hasNext()) {
        Atom a = it.next();
        predicates.add(a.getPredicate());
    }
    return predicates;
}
Also used : DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Atom(fr.lirmm.graphik.graal.api.core.Atom) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) HashSet(java.util.HashSet)

Example 73 with Predicate

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

the class OWLEquivalentClassExpressionVisitorImpl method visit.

// /////////////////////////////////////////////////////////////////////////
// PUBLIC METHODS
// /////////////////////////////////////////////////////////////////////////
@Override
public InMemoryAtomSet visit(OWLClass arg) {
    Predicate p = GraalUtils.createPredicate(arg);
    Atom a = DefaultAtomFactory.instance().create(p, glueVariable);
    return GraalUtils.createAtomSet(a);
}
Also used : DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Atom(fr.lirmm.graphik.graal.api.core.Atom) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Example 74 with Predicate

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

the class AbstractRDFListener method handleStatement.

@Override
public void handleStatement(Statement st) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(st.toString());
    }
    Predicate predicate = new Predicate(new DefaultURI(st.getPredicate().toString()), 2);
    Term subject = DefaultTermFactory.instance().createConstant(new DefaultURI(st.getSubject().toString()));
    Term object;
    fr.lirmm.graphik.util.URI datatype;
    if (st.getObject() instanceof Literal) {
        Literal l = (Literal) st.getObject();
        if (l.getDatatype() == null) {
            datatype = URIUtils.RDF_LANG_STRING;
        } else {
            datatype = new fr.lirmm.graphik.util.DefaultURI(l.getDatatype().getNamespace(), l.getDatatype().getLocalName());
        }
        String value = l.getLabel();
        if (datatype.equals(URIUtils.RDF_LANG_STRING)) {
            value += "@" + l.getLanguage();
        }
        object = DefaultTermFactory.instance().createLiteral(datatype, value);
    } else {
        object = DefaultTermFactory.instance().createConstant(new DefaultURI(st.getObject().toString()));
    }
    DefaultAtom a = new DefaultAtom(predicate, subject, object);
    this.createAtom(a);
}
Also used : DefaultURI(fr.lirmm.graphik.util.DefaultURI) Literal(org.eclipse.rdf4j.model.Literal) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Term(fr.lirmm.graphik.graal.api.core.Term) DefaultURI(fr.lirmm.graphik.util.DefaultURI) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Example 75 with Predicate

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

the class PrefixMapperTest method testUnmapPredicate.

/**
 * Test method for {@link fr.lirmm.graphik.graal.core.mapper.PrefixMapper#unmap(fr.lirmm.graphik.graal.api.core.Predicate)}.
 */
@Test
public void testUnmapPredicate() {
    // Given
    Predicate p = new Predicate("prefix#p", 1);
    Mapper mapper = new PrefixMapper("prefix#");
    // When
    Predicate mapped = mapper.unmap(p);
    // Then
    Assert.assertEquals(new Predicate("p", 1), mapped);
}
Also used : Mapper(fr.lirmm.graphik.graal.api.core.mapper.Mapper) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) Test(org.junit.Test)

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