Search in sources :

Example 1 with DefaultAtom

use of fr.lirmm.graphik.graal.core.DefaultAtom 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 DefaultAtom

use of fr.lirmm.graphik.graal.core.DefaultAtom 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 3 with DefaultAtom

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

the class OWLEquivalentClassExpressionVisitorImpl method objectMinCardinality0.

@Override
public InMemoryAtomSet objectMinCardinality0(OWLObjectMinCardinality arg) {
    InMemoryAtomSet atomset = GraalUtils.createAtomSet();
    atomset.add(new DefaultAtom(Predicate.TOP, glueVariable));
    return atomset;
}
Also used : DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)

Example 4 with DefaultAtom

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

the class Atom2SubstitutionConverterTest method githubIssue2variant1.

@Test
public void githubIssue2variant1() throws ParseException {
    // given
    Predicate p = DefaultPredicateFactory.instance().create("p", 1);
    Variable x = DefaultTermFactory.instance().createVariable("X");
    Variable y = DefaultTermFactory.instance().createVariable("Y");
    Atom queryAtom = new DefaultAtom(p, x);
    List<Term> ansList = new LinkedList<>();
    ansList.add(x);
    ansList.add(y);
    // when
    Converter<Atom, Substitution> converter = new Atom2SubstitutionConverter(queryAtom, ansList);
    Substitution s = null;
    try {
        s = converter.convert(DlgpParser.parseAtom("p(a)."));
    } catch (ConversionException e) {
        fail();
    }
    // then
    Constant a = DefaultTermFactory.instance().createConstant("a");
    assertEquals(a, s.createImageOf(x));
    assertEquals(y, s.createImageOf(y));
}
Also used : ConversionException(fr.lirmm.graphik.util.stream.converter.ConversionException) Variable(fr.lirmm.graphik.graal.api.core.Variable) Substitution(fr.lirmm.graphik.graal.api.core.Substitution) Constant(fr.lirmm.graphik.graal.api.core.Constant) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Term(fr.lirmm.graphik.graal.api.core.Term) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Atom(fr.lirmm.graphik.graal.api.core.Atom) LinkedList(java.util.LinkedList) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) Test(org.junit.Test)

Example 5 with DefaultAtom

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

the class Atom2SubstitutionConverterTest method basic.

@Test
public void basic() throws ParseException {
    // given
    Predicate p = DefaultPredicateFactory.instance().create("p", 1);
    Variable x = DefaultTermFactory.instance().createVariable("X");
    Atom queryAtom = new DefaultAtom(p, x);
    List<Term> ansList = new LinkedList<>();
    ansList.add(x);
    // when
    Converter<Atom, Substitution> converter = new Atom2SubstitutionConverter(queryAtom, ansList);
    Substitution s = null;
    try {
        s = converter.convert(DlgpParser.parseAtom("p(a)."));
    } catch (ConversionException e) {
        fail();
    }
    // then
    Constant a = DefaultTermFactory.instance().createConstant("a");
    assertEquals(a, s.createImageOf(x));
}
Also used : ConversionException(fr.lirmm.graphik.util.stream.converter.ConversionException) Variable(fr.lirmm.graphik.graal.api.core.Variable) Substitution(fr.lirmm.graphik.graal.api.core.Substitution) Constant(fr.lirmm.graphik.graal.api.core.Constant) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Term(fr.lirmm.graphik.graal.api.core.Term) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Atom(fr.lirmm.graphik.graal.api.core.Atom) LinkedList(java.util.LinkedList) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) Test(org.junit.Test)

Aggregations

DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)45 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)25 Term (fr.lirmm.graphik.graal.api.core.Term)25 Atom (fr.lirmm.graphik.graal.api.core.Atom)21 Test (org.junit.Test)20 LinkedList (java.util.LinkedList)17 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)12 LinkedListRuleSet (fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)7 Rule (fr.lirmm.graphik.graal.api.core.Rule)7 RuleSet (fr.lirmm.graphik.graal.api.core.RuleSet)7 Variable (fr.lirmm.graphik.graal.api.core.Variable)6 ConversionException (fr.lirmm.graphik.util.stream.converter.ConversionException)6 Constant (fr.lirmm.graphik.graal.api.core.Constant)5 DefaultURI (fr.lirmm.graphik.util.DefaultURI)5 Pair (org.apache.commons.lang3.tuple.Pair)5 DefaultRule (fr.lirmm.graphik.graal.core.DefaultRule)4 AnalyserRuleSet (fr.lirmm.graphik.graal.rulesetanalyser.util.AnalyserRuleSet)4 RulesCompilation (fr.lirmm.graphik.graal.api.core.RulesCompilation)3