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 == '<');
}
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);
}
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>)."));
}
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));
}
}
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;
}
Aggregations