Search in sources :

Example 11 with DefaultAtom

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

the class DlgpWriterTest method writePredicate.

@Test
public void writePredicate() throws IOException {
    Predicate p = new Predicate("P", 1);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    DlgpWriter writer = new DlgpWriter(os);
    writer.write(new DefaultAtom(p, cst));
    writer.flush();
    String s = new String(os.toByteArray(), "UTF-8");
    writer.close();
    Character c = s.charAt(0);
    Assert.assertTrue("Predicate label does not begin with lower case or double quote.", Character.isLowerCase(c) || c == '<');
}
Also used : DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) Test(org.junit.Test)

Example 12 with DefaultAtom

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

the class DlgpWriterTest method writeURIForbiddenChars.

@Test
public void writeURIForbiddenChars() throws IOException {
    Predicate p = new Predicate(new DefaultURI("/< >\"{}|^`\\/"), 1);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    DlgpWriter writer = new DlgpWriter(os);
    writer.write(new DefaultAtom(p, cst));
    writer.flush();
    String s = new String(os.toByteArray(), "UTF-8");
    writer.close();
    System.out.println(s);
    Assert.assertEquals("</\\u003c\\u0020\\u003e\\u0022\\u007b\\u007d\\u007c\\u005e\\u0060\\u005c/>(<A>).\n", s);
}
Also used : DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DefaultURI(fr.lirmm.graphik.util.DefaultURI) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) Test(org.junit.Test)

Example 13 with DefaultAtom

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

the class DlgpWriterTest method bug76.

@Test
public void bug76() throws IOException {
    Prefix p1 = new Prefix("a", "http://p#");
    Prefix p2 = new Prefix("b", "http://p#p/");
    Predicate p = new Predicate(new DefaultURI("http://p#p/toto"), 1);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    DlgpWriter writer = new DlgpWriter(os);
    writer.write(p1);
    writer.write(p2);
    writer.write(new DefaultAtom(p, cst));
    writer.flush();
    String s = new String(os.toByteArray(), "UTF-8");
    writer.close();
    Assert.assertTrue(s.contains("b:toto(<A>)."));
}
Also used : DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Prefix(fr.lirmm.graphik.util.Prefix) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DefaultURI(fr.lirmm.graphik.util.DefaultURI) Predicate(fr.lirmm.graphik.graal.api.core.Predicate) Test(org.junit.Test)

Example 14 with DefaultAtom

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

the class TestUtil method addNAtoms.

public static void addNAtoms(InMemoryAtomSet to, int n, Predicate[] predicates, int domainSize, Random rand) {
    for (int i = 0; i < n; ++i) {
        int p = rand.nextInt(predicates.length);
        List<Term> terms = new LinkedList<Term>();
        for (int j = 0; j < predicates[p].getArity(); ++j) {
            terms.add(DefaultTermFactory.instance().createConstant(rand.nextInt(domainSize)));
        }
        to.add(new DefaultAtom(predicates[p], terms));
    }
}
Also used : DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Term(fr.lirmm.graphik.graal.api.core.Term) LinkedList(java.util.LinkedList)

Example 15 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)

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