use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.
the class DlgpWriterTest method writeValideURI.
@Test
public void writeValideURI() throws IOException {
String uri = "/a//a///a////a/////a//////" + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "´áéíóúýàèìòùỳ¨äëïöüÿâêîôûŷ" + "?¿.:,;!¡~'" + "0123456789₀₁₂₃₄₅₆₇₈₉₍₎₊₋₌ₐₑₒₓₔ⁰¹⁴⁵⁶⁷⁸⁹⁺⁽⁾⁼⁻" + "+-*%=()[]«»_—–#" + "ßæœçåÅøØĐħĦ" + "€$¤£" + "¶¦¬©®™ªº♯♮♭" + "ΑΒΔΕΦΓΗΙΘΚΛΜΝΟΠΧΡΣΤΥΩΞΨΖαβδεφγηιθκλμνοπχρστυωξψζ" + "‰≃≠≮≯≤≥≰≱≲≳Ω¼½¾ƒℓ⅓⅔⅛⅜⅝⅞⩽⩾←↑→↓↔↦⇒⇔∂∙∏∑∆∇√∞∫≈≡∀∃∈∉∪∩⊂⊃♀♂ℝℂℚℕℤℍ⊥‖∧∨⟦⟧⟨⟩∘" + // unbreakable spaces
" " + "////";
Predicate p = new Predicate(new DefaultURI(uri), 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();
Assert.assertTrue(s.contains("<" + uri + ">(<A>)."));
}
use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.
the class DlgpWriterTest method bugIllegalCharInPrefixedName.
@Test
public void bugIllegalCharInPrefixedName() throws IOException {
Prefix p1 = new Prefix("a", "http://p#");
Predicate p = new Predicate(new DefaultURI("http://p#to@to"), 1);
ByteArrayOutputStream os = new ByteArrayOutputStream();
DlgpWriter writer = new DlgpWriter(os);
writer.write(p1);
writer.write(new DefaultAtom(p, cst));
writer.flush();
String s = new String(os.toByteArray(), "UTF-8");
writer.close();
Assert.assertTrue(s.contains("<http://p#to@to>(<A>)."));
}
use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.
the class ForwardCheckingTest method NFC2Test2.
@Test
public void NFC2Test2() throws HomomorphismException, IteratorException, ParseException {
Profiler profiler = new CPUTimeProfiler();
Predicate[] predicates = { new Predicate("p", 2), new Predicate("q", 2), new Predicate("r", 2) };
InMemoryAtomSet data = new DefaultInMemoryGraphStore();
TestUtil.addNAtoms(data, 32, predicates, 5, new Random(0));
ConjunctiveQuery query = DlgpParser.parseQuery("?(X,Y,Z) :- p(X,Y), q(X,Z), r(Y,Z).");
Homomorphism<ConjunctiveQuery, AtomSet> h = new BacktrackHomomorphism(new NFC2());
h.setProfiler(profiler);
CloseableIterator<Substitution> results = h.execute(query, data);
while (results.hasNext()) {
results.next();
}
results.close();
}
use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.
the class GraalUtils method createPredicate.
/**
* @param property
* @return a {@link Predicate} with arity 2 which represents the specified owl data property.
*/
public static Predicate createPredicate(OWLDataPropertyExpression property) {
Predicate predicate = null;
URI uri = convertIRI(property.asOWLDataProperty().getIRI());
predicate = new Predicate(uri, 2);
return predicate;
}
use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.
the class Atom2SubstitutionConverterTest method basic2.
@Test
public void basic2() throws ParseException {
// given
Predicate p = DefaultPredicateFactory.instance().create("p", 3);
Variable x = DefaultTermFactory.instance().createVariable("X");
Variable y = DefaultTermFactory.instance().createVariable("Y");
Variable z = DefaultTermFactory.instance().createVariable("Z");
Atom queryAtom = new DefaultAtom(p, x, y, z);
List<Term> ansList = new LinkedList<>();
ansList.add(x);
ansList.add(z);
// when
Converter<Atom, Substitution> converter = new Atom2SubstitutionConverter(queryAtom, ansList);
Substitution s = null;
try {
s = converter.convert(DlgpParser.parseAtom("p(a,b,c)."));
} catch (ConversionException e) {
fail();
}
// then
Constant a = DefaultTermFactory.instance().createConstant("a");
Constant c = DefaultTermFactory.instance().createConstant("c");
assertEquals(a, s.createImageOf(x));
assertEquals(y, s.createImageOf(y));
assertEquals(c, s.createImageOf(z));
}
Aggregations