use of fr.lirmm.graphik.graal.core.DefaultAtom in project graal by graphik-team.
the class AbstractDlgpListener method createsEquality.
@Override
public void createsEquality(Object term1, Object term2) {
atom = new DefaultAtom(Predicate.EQUALITY, createTerm(term1), createTerm(term2));
this.atomSet.add(atom);
}
use of fr.lirmm.graphik.graal.core.DefaultAtom in project graal by graphik-team.
the class AbstractDlgpListener method createsAtom.
@Override
public void createsAtom(Object predicate, Object[] terms) {
List<Term> list = new LinkedList<Term>();
for (Object t : terms) {
list.add(createTerm(t));
}
atom = new DefaultAtom(createPredicate(predicate, terms.length), list);
this.atomSet.add(atom);
}
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));
}
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));
}
use of fr.lirmm.graphik.graal.core.DefaultAtom in project graal by graphik-team.
the class DlgpWriterTest method writeConstant.
@Test
public void writeConstant() throws IOException {
Term a = DefaultTermFactory.instance().createConstant("A");
ByteArrayOutputStream os = new ByteArrayOutputStream();
DlgpWriter writer = new DlgpWriter(os);
writer.write(new DefaultAtom(predicat, a));
writer.flush();
String s = new String(os.toByteArray(), "UTF-8");
writer.close();
char c = s.charAt(s.indexOf("(") + 1);
Assert.assertTrue("Constant label does not begin with lower case.", Character.isLowerCase(c) || c == '<');
}
Aggregations