Search in sources :

Example 96 with InMemoryAtomSet

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

the class AbstractMapper method unmap.

@Override
public InMemoryAtomSet unmap(InMemoryAtomSet atomset) {
    InMemoryAtomSet mapped;
    try {
        mapped = atomset.getClass().newInstance();
    } catch (InstantiationException e) {
        mapped = new LinkedListAtomSet();
    } catch (IllegalAccessException e) {
        mapped = new LinkedListAtomSet();
    }
    CloseableIteratorWithoutException<Atom> it = atomset.iterator();
    while (it.hasNext()) {
        mapped.add(this.unmap(it.next()));
    }
    it.close();
    return mapped;
}
Also used : InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) Atom(fr.lirmm.graphik.graal.api.core.Atom)

Example 97 with InMemoryAtomSet

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

the class AbstractMapper method unmap.

@Override
public Rule unmap(Rule rule) {
    InMemoryAtomSet body = this.unmap(rule.getBody());
    InMemoryAtomSet head = this.unmap(rule.getHead());
    return DefaultRuleFactory.instance().create(rule.getLabel(), body, head);
}
Also used : InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)

Example 98 with InMemoryAtomSet

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

the class AtomSetUtils method minus.

public static InMemoryAtomSet minus(InMemoryAtomSet a1, InMemoryAtomSet a2) {
    InMemoryAtomSet atomset = DefaultAtomSetFactory.instance().create();
    CloseableIteratorWithoutException<Atom> it = a1.iterator();
    while (it.hasNext()) {
        Atom a = it.next();
        if (!a2.contains(a)) {
            atomset.add(a);
        }
    }
    return atomset;
}
Also used : InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Atom(fr.lirmm.graphik.graal.api.core.Atom)

Example 99 with InMemoryAtomSet

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

the class AtomSetUtils method union.

public static InMemoryAtomSet union(InMemoryAtomSet a1, InMemoryAtomSet a2) {
    InMemoryAtomSet atomset = DefaultAtomSetFactory.instance().create();
    CloseableIteratorWithoutException<Atom> it = a1.iterator();
    while (it.hasNext()) {
        Atom a = it.next();
        atomset.add(new DefaultAtom(a));
    }
    it = a2.iterator();
    while (it.hasNext()) {
        Atom a = it.next();
        if (!atomset.contains(a)) {
            atomset.add(new DefaultAtom(a));
        }
    }
    return atomset;
}
Also used : DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Atom(fr.lirmm.graphik.graal.api.core.Atom)

Example 100 with InMemoryAtomSet

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

the class OWL2ParserTest method objectOneOf1.

@Test
public void objectOneOf1() throws OWL2ParserException {
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + " [ owl:oneOf ( :i1 ) ] " + " rdfs:subClassOf :A . ");
    int nbRules = 0;
    while (parser.hasNext()) {
        Object o = parser.next();
        if (o instanceof InMemoryAtomSet) {
            ++nbRules;
            InMemoryAtomSet a = (InMemoryAtomSet) o;
            CloseableIteratorWithoutException<Atom> bodyIt = a.iterator();
            Assert.assertTrue(bodyIt.hasNext());
            Atom body = bodyIt.next();
            Assert.assertFalse(bodyIt.hasNext());
            Assert.assertEquals(A, body.getPredicate());
            Assert.assertTrue(!body.getTerm(0).isConstant() || body.getTerm(0).equals(I1));
        }
    }
    parser.close();
    Assert.assertEquals("Number of assertions found:", 1, nbRules);
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Atom(fr.lirmm.graphik.graal.api.core.Atom) Test(org.junit.Test)

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