Search in sources :

Example 1 with DefaultNegativeConstraint

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

the class OWLAxiomParser method visit.

@Override
public Iterable<? extends Object> visit(OWLDifferentIndividualsAxiom arg) {
    Collection<Object> c = GraalUtils.<Object>createCollection();
    LinkedList<OWLIndividual> list = new LinkedList<OWLIndividual>(arg.getIndividualsAsList());
    Iterator<OWLIndividual> it1, it2;
    it1 = list.iterator();
    while (it1.hasNext()) {
        OWLIndividual individu1 = it1.next();
        it1.remove();
        Term t1 = GraalUtils.createTerm(individu1);
        it2 = list.iterator();
        while (it2.hasNext()) {
            OWLIndividual individu2 = it2.next();
            Term t2 = GraalUtils.createTerm(individu2);
            Atom a = new DefaultAtom(equalityPredicate, t1, t2);
            c.add(new DefaultNegativeConstraint(new LinkedListAtomSet(a)));
        }
    }
    return c;
}
Also used : DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) Term(fr.lirmm.graphik.graal.api.core.Term) LinkedList(java.util.LinkedList) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Atom(fr.lirmm.graphik.graal.api.core.Atom) OWLIndividual(org.semanticweb.owlapi.model.OWLIndividual)

Example 2 with DefaultNegativeConstraint

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

the class OWLAxiomParser method visit.

@Override
public Iterable<? extends Object> visit(OWLNegativeObjectPropertyAssertionAxiom arg) {
    freeVarGen.setIndex(0);
    Term a = GraalUtils.createTerm(arg.getSubject());
    Term b = GraalUtils.createTerm(arg.getObject());
    InMemoryAtomSet atomset = arg.getProperty().accept(new OWLPropertyExpressionVisitorImpl(a, b));
    return Collections.singleton(new DefaultNegativeConstraint(atomset));
}
Also used : DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) Term(fr.lirmm.graphik.graal.api.core.Term)

Example 3 with DefaultNegativeConstraint

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

the class OWLAxiomParser method disjointPropertiesAxiom.

private Iterable<? extends Object> disjointPropertiesAxiom(Iterable<? extends OWLPropertyExpression> properties) {
    Collection<Rule> rules = GraalUtils.<Rule>createCollection();
    InMemoryAtomSet a, a1, a2;
    Iterator<? extends OWLPropertyExpression> it1, it2;
    it1 = properties.iterator();
    while (it1.hasNext()) {
        OWLPropertyExpression propExpr = (OWLPropertyExpression) it1.next();
        a1 = propExpr.accept(propertyVisitorXY);
        it1.remove();
        it2 = properties.iterator();
        while (it2.hasNext()) {
            OWLPropertyExpression next = (OWLPropertyExpression) it2.next();
            a2 = next.accept(propertyVisitorXY);
            a = GraalUtils.createAtomSet();
            a.addAll(a1);
            a.addAll(a2);
            rules.add(new DefaultNegativeConstraint(a));
        }
    }
    return rules;
}
Also used : OWLPropertyExpression(org.semanticweb.owlapi.model.OWLPropertyExpression) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) Rule(fr.lirmm.graphik.graal.api.core.Rule) SWRLRule(org.semanticweb.owlapi.model.SWRLRule)

Example 4 with DefaultNegativeConstraint

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

the class AbstractDlgpListener method endsConjunction.

@Override
public void endsConjunction(OBJECT_TYPE objectType) {
    switch(objectType) {
        case QUERY:
            Set<Variable> bodyVars = this.atomSet.getVariables();
            for (Term t : this.answerVars) {
                if (t.isVariable() && !bodyVars.contains(t)) {
                    throw new ParseError("The variable [" + t + "] of the answer list does not appear in the query body.");
                }
            }
            this.createQuery(DefaultConjunctiveQueryFactory.instance().create(this.label, this.atomSet, this.answerVars));
            break;
        case NEG_CONSTRAINT:
            this.createNegConstraint(new DefaultNegativeConstraint(this.label, this.atomSet));
            break;
        case RULE:
            if (this.atomSet2 == null) {
                this.atomSet2 = this.atomSet;
                this.atomSet = new LinkedListAtomSet();
            } else {
                this.createRule(DefaultRuleFactory.instance().create(this.label, this.atomSet, this.atomSet2));
            }
            break;
        case FACT:
            this.createAtomSet(this.atomSet);
            break;
        default:
            break;
    }
}
Also used : DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Variable(fr.lirmm.graphik.graal.api.core.Variable) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) ParseError(fr.lirmm.graphik.graal.api.io.ParseError) Term(fr.lirmm.graphik.graal.api.core.Term)

Example 5 with DefaultNegativeConstraint

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

the class OWLAxiomParser method visit.

@Override
public Iterable<? extends Object> visit(OWLNegativeDataPropertyAssertionAxiom arg) {
    freeVarGen.setIndex(0);
    Term a = GraalUtils.createTerm(arg.getSubject());
    Term b = GraalUtils.createLiteral(arg.getObject());
    InMemoryAtomSet atomset = arg.getProperty().accept(new OWLPropertyExpressionVisitorImpl(a, b));
    return Collections.singleton(new DefaultNegativeConstraint(atomset));
}
Also used : DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) Term(fr.lirmm.graphik.graal.api.core.Term)

Aggregations

DefaultNegativeConstraint (fr.lirmm.graphik.graal.core.DefaultNegativeConstraint)12 OWL2Parser (fr.lirmm.graphik.graal.io.owl.OWL2Parser)6 Test (org.junit.Test)6 Atom (fr.lirmm.graphik.graal.api.core.Atom)5 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)5 Term (fr.lirmm.graphik.graal.api.core.Term)4 Rule (fr.lirmm.graphik.graal.api.core.Rule)2 LinkedListAtomSet (fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet)2 Variable (fr.lirmm.graphik.graal.api.core.Variable)1 ParseError (fr.lirmm.graphik.graal.api.io.ParseError)1 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)1 OWL2ParserException (fr.lirmm.graphik.graal.io.owl.OWL2ParserException)1 CloseableIteratorWithoutException (fr.lirmm.graphik.util.stream.CloseableIteratorWithoutException)1 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)1 LinkedList (java.util.LinkedList)1 OWLIndividual (org.semanticweb.owlapi.model.OWLIndividual)1 OWLPropertyExpression (org.semanticweb.owlapi.model.OWLPropertyExpression)1 SWRLRule (org.semanticweb.owlapi.model.SWRLRule)1