use of nars.term.Compound in project narchy by automenta.
the class NarseseExtendedTest method testAnonymousVariable.
@Test
public void testAnonymousVariable() throws Narsese.NarseseException {
// (_,_) must be converted to (#1,#2)
String input = "((_,_) <-> x)";
Compound x = term(input);
// Terms.printRecursive(System.out, x);
assertEquals("((_,_)<->x)", x.toString());
Term y = x.normalize();
// Terms.printRecursive(System.out, y);
assertEquals("((#1,#2)<->x)", y.toString());
Task question = task(x + "?");
assertEquals("((#1,#2)<->x)?", question.toStringWithoutBudget());
Task belief = task(x + ".");
assertEquals("((#1,#2)<->x). %1.0;.90%", belief.toStringWithoutBudget());
}
use of nars.term.Compound in project narchy by automenta.
the class NarseseExtendedTest method testNegation3.
@Test
public void testNegation3() throws Narsese.NarseseException {
assertEquals("(--,(x))", term("--(x)").toString());
assertEquals("(--,(x))", term("-- (x)").toString());
assertEquals("(--,(x&&y))", term("-- (x && y)").toString());
assertEquals(term("(goto(z) ==>+5 --(x))"), term("(goto(z) ==>+5 (--,(x)))"));
assertEquals(term("(goto(z) ==>+5 --x:y)"), term("(goto(z) ==>+5 (--,x:y))"));
Compound nab = term("--(a & b)");
assertSame(nab.op(), Op.NEG);
assertSame(nab.sub(0).op(), Op.SECTe);
// try {
// task("(-- negated illegal_extra_term)!");
// assertTrue(false);
// } catch (Exception e) {
// }
}
use of nars.term.Compound in project narchy by automenta.
the class NarseseExtendedTest method testColonReverseInheritance.
@Test
public void testColonReverseInheritance() throws Narsese.NarseseException {
Compound t = term("namespace:named");
assertEquals(Op.INH, t.op());
assertEquals("named", t.sub(0).toString());
assertEquals("namespace", t.sub(1).toString());
Compound u = term("<a:b --> c:d>");
assertEquals("((b-->a)-->(d-->c))", u.toString());
Task ut = task("<a:b --> c:d>.");
assertNotNull(ut);
assertEquals(ut.term(), u);
}
use of nars.term.Compound in project narchy by automenta.
the class TermIOTest method testTermSerialization3_2.
@Test
public void testTermSerialization3_2() throws Narsese.NarseseException {
// multiple variables
Variable q = $.varQuery(1);
Compound twoB = $.inh($.varDep(2), Atomic.the("b"));
assertNotEquals(q.compareTo(twoB), twoB.compareTo(q));
assertTermEqualSerialize("((#a --> b) <-> ?c)");
Term a = $("(#2-->b)");
Term b = $("?1");
int x = a.compareTo(b);
int y = b.compareTo(a);
assertNotEquals((int) Math.signum(x), (int) Math.signum(y));
}
use of nars.term.Compound in project narchy by automenta.
the class DynamicTruthBeliefTableTest method testDynamicConjunction2Temporal.
@Test
public void testDynamicConjunction2Temporal() throws Narsese.NarseseException {
NAR n = NARS.shell();
n.believe($("(x)"), (long) 0);
n.believe($("(y)"), (long) 4);
n.time.dur(8);
TaskConcept cc = (TaskConcept) n.conceptualize($("((x) && (y))"));
DynamicTruthBeliefTable xtable = (DynamicTruthBeliefTable) cc.beliefs();
Compound template = $("((x) &&+4 (y))");
DynTruth xt = xtable.truth(0, 0, template, n);
assertNotNull(xt);
// assertTrue($.t(1f, 0.81f).equals(xt.truth(n), 0.1f), xt.truth(n).toString());
// best match to the input
assertEquals(0.81f, xtable.taskDynamic(0, 0, $("((x) &&+4 (y))"), n).conf(), 0.05f);
assertEquals(0.74f, xtable.taskDynamic(0, 0, $("((x) &&+6 (y))"), n).conf(), 0.07f);
assertEquals(0.75f, xtable.taskDynamic(0, 0, $("((x) &&+2 (y))"), n).conf(), 0.07f);
assertEquals(0.75f, xtable.taskDynamic(0, 0, $("((x) &&+0 (y))"), n).conf(), 0.07f);
assertEquals(0.62f, xtable.taskDynamic(0, 0, $("((x) &&-32 (y))"), n).conf(), 0.2f);
}
Aggregations