Search in sources :

Example 1 with InMemoryAtomSet

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

the class OWLAxiomParser method functionalPropertyAxiom.

// /////////////////////////////////////////////////////////////////////////
// PRIVATE METHODS
// /////////////////////////////////////////////////////////////////////////
private Iterable<? extends Object> functionalPropertyAxiom(OWLPropertyExpression property) {
    InMemoryAtomSet body = property.accept(propertyVisitorXY);
    body.addAll(property.accept(propertyVisitorXZ));
    InMemoryAtomSet head = GraalUtils.createAtomSet(new DefaultAtom(equalityPredicate, glueVarY, glueVarZ));
    return Collections.<Rule>singleton(DefaultRuleFactory.instance().create(body, head));
}
Also used : DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) Rule(fr.lirmm.graphik.graal.api.core.Rule) SWRLRule(org.semanticweb.owlapi.model.SWRLRule)

Example 2 with InMemoryAtomSet

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

the class OWLAxiomParser method visit.

// /////////////////////////////////////////////////////////////////////////
// PropertyChain
// /////////////////////////////////////////////////////////////////////////
@Override
public Iterable<? extends Object> visit(OWLSubPropertyChainOfAxiom arg) {
    freeVarGen.setIndex(0);
    InMemoryAtomSet body = GraalUtils.createAtomSet();
    Term varX, varY, firstVarInChain;
    firstVarInChain = varX = freeVarGen.getFreshSymbol();
    for (OWLPropertyExpression pe : arg.getPropertyChain()) {
        varY = freeVarGen.getFreshSymbol();
        body.addAll(pe.accept(new OWLPropertyExpressionVisitorImpl(varX, varY)));
        varX = varY;
    }
    InMemoryAtomSet head = arg.getSuperProperty().accept(new OWLPropertyExpressionVisitorImpl(firstVarInChain, varX));
    return Collections.singleton(DefaultRuleFactory.instance().create(body, head));
}
Also used : OWLPropertyExpression(org.semanticweb.owlapi.model.OWLPropertyExpression) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) Term(fr.lirmm.graphik.graal.api.core.Term)

Example 3 with InMemoryAtomSet

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

the class OWLAxiomParser method visit.

// /////////////////////////////////////////////////////////////////////////
// DataPropertyAxiom
// /////////////////////////////////////////////////////////////////////////
@Override
public Iterable<? extends Object> visit(OWLSubDataPropertyOfAxiom arg) {
    InMemoryAtomSet a1, a2;
    a1 = arg.getSubProperty().accept(propertyVisitorXY);
    a2 = arg.getSuperProperty().accept(propertyVisitorXY);
    return Collections.singleton(DefaultRuleFactory.instance().create(a1, a2));
}
Also used : InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)

Example 4 with InMemoryAtomSet

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

the class OWLAxiomParser method visit.

@Override
public Iterable<? extends Object> visit(OWLDataPropertyRangeAxiom arg) {
    InMemoryAtomSet body = arg.getProperty().accept(propertyVisitorYX);
    InMemoryAtomSet head = null;
    try {
        head = arg.getRange().accept(dataRangeVisitorX);
    } catch (UnsupportedConstructor e) {
        if (LOGGER.isWarnEnabled()) {
            LOGGER.warn("[ " + e.getConstructor() + "] is not supported here. This axioms was skipped : " + arg);
        }
        return Collections.emptyList();
    }
    return Collections.singleton(DefaultRuleFactory.instance().create(body, head));
}
Also used : InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)

Example 5 with InMemoryAtomSet

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

the class OWLAxiomParser method visit.

// /////////////////////////////////////////////////////////////////////////
// HasKey
// /////////////////////////////////////////////////////////////////////////
@Override
public Iterable<? extends Object> visit(OWLHasKeyAxiom arg) {
    // =(Y, Z) :- C(Y), C(Z), p1(Y, X1), p1(Z, X1), ..., pn(Y, Xn), pn(Z,
    // Xn).
    Collection<Rule> rules = GraalUtils.<Rule>createCollection();
    freeVarGen.setIndex(2);
    InMemoryAtomSet head = GraalUtils.createAtomSet(DefaultAtomFactory.instance().create(equalityPredicate, glueVarX, glueVarY));
    OWLClassExpression classExpression = OWLAPIUtils.classExpressionDisjunctiveNormalForm(arg.getClassExpression());
    for (Pair<OWLClassExpression, OWLClassExpression> pair : MathUtils.selfCartesianProduct(OWLAPIUtils.getObjectUnionOperands(classExpression))) {
        InMemoryAtomSet body = pair.getLeft().accept(classVisitorX);
        body.addAll(pair.getRight().accept(classVisitorY));
        for (OWLObjectPropertyExpression pe : arg.getObjectPropertyExpressions()) {
            Term var = freeVarGen.getFreshSymbol();
            body.addAll(pe.accept(new OWLPropertyExpressionVisitorImpl(glueVarX, var)));
            body.addAll(pe.accept(new OWLPropertyExpressionVisitorImpl(glueVarY, var)));
        }
        for (OWLDataPropertyExpression pe : arg.getDataPropertyExpressions()) {
            Term var = freeVarGen.getFreshSymbol();
            body.add(DefaultAtomFactory.instance().create(GraalUtils.createPredicate(pe), glueVarX, var));
            body.add(DefaultAtomFactory.instance().create(GraalUtils.createPredicate(pe), glueVarY, var));
        }
        rules.add(DefaultRuleFactory.instance().create(body, head));
    }
    return rules;
}
Also used : OWLDataPropertyExpression(org.semanticweb.owlapi.model.OWLDataPropertyExpression) OWLObjectPropertyExpression(org.semanticweb.owlapi.model.OWLObjectPropertyExpression) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) Rule(fr.lirmm.graphik.graal.api.core.Rule) SWRLRule(org.semanticweb.owlapi.model.SWRLRule) OWLClassExpression(org.semanticweb.owlapi.model.OWLClassExpression) Term(fr.lirmm.graphik.graal.api.core.Term)

Aggregations

InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)122 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)40 Atom (fr.lirmm.graphik.graal.api.core.Atom)38 LinkedListAtomSet (fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet)35 Test (org.junit.Test)35 Term (fr.lirmm.graphik.graal.api.core.Term)31 Rule (fr.lirmm.graphik.graal.api.core.Rule)25 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)23 LinkedList (java.util.LinkedList)22 DefaultInMemoryGraphStore (fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore)21 Variable (fr.lirmm.graphik.graal.api.core.Variable)19 HomomorphismException (fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException)10 DefaultNegativeConstraint (fr.lirmm.graphik.graal.core.DefaultNegativeConstraint)10 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)9 Theory (org.junit.experimental.theories.Theory)9 AtomSet (fr.lirmm.graphik.graal.api.core.AtomSet)8 DefaultConjunctiveQueryWithNegatedParts (fr.lirmm.graphik.graal.core.DefaultConjunctiveQueryWithNegatedParts)8 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)8 OWL2Parser (fr.lirmm.graphik.graal.io.owl.OWL2Parser)7 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)6