use of nars.term.Compound in project narchy by automenta.
the class NarseseBaseTest method testProduct.
@Test
public void testProduct() throws Narsese.NarseseException {
Compound pt = term("(a, b, c)");
assertNotNull(pt);
assertEquals(PROD, pt.op());
testProductABC(pt);
// with optional prefix
testProductABC(term("(*,a,b,c)"));
// without spaces
testProductABC(term("(a,b,c)"));
// additional spaces
testProductABC(term("(a, b, c)"));
// additional spaces
testProductABC(term("(a , b, c)"));
// additional spaces
testProductABC(term("(a , b , c)"));
// tab
testProductABC(term("(a ,\tb, c)"));
// testProductABC(term("(a b c)")); //without commas
// testProductABC(term("(a * b * c)")); //with multiple (redundant) infix
}
use of nars.term.Compound in project narchy by automenta.
the class NarseseBaseTest method testOperationEquivalenceWithOper.
@Test
public void testOperationEquivalenceWithOper() throws Narsese.NarseseException {
Term a;
a = term("a(b,c)");
Compound b = term("((b,c) --> a)");
assertEquals(a, b);
assertEquals(a.op(), b.op());
assertEquals(a.getClass(), b.getClass());
assertEquals(Op.ATOM, b.sub(1).op());
}
use of nars.term.Compound in project narchy by automenta.
the class NarseseBaseTest method testInfix2.
@Test
public void testInfix2() throws Narsese.NarseseException {
Compound t = term("(x & y)");
assertEquals(Op.SECTe, t.op());
assertEquals(2, t.subs());
assertEquals("x", t.sub(0).toString());
assertEquals("y", t.sub(1).toString());
Compound a = term("(x | y)");
assertEquals(Op.SECTi, a.op());
assertEquals(2, a.subs());
Compound b = term("(x * y)");
assertEquals(PROD, b.op());
assertEquals(2, b.subs());
Compound c = term("(<a -->b> && y)");
assertEquals(Op.CONJ, c.op());
assertEquals(2, c.subs());
assertEquals(5, c.complexity());
// heavier term on the left
assertEquals(Op.INH, c.sub(0).op());
}
use of nars.term.Compound in project narchy by automenta.
the class NarseseBaseTest method testSet.
@Test
public void testSet() throws Narsese.NarseseException {
Compound xInt = term("[x]");
assertEquals(Op.SETi, xInt.op());
assertEquals(1, xInt.subs());
assertEquals("x", xInt.sub(0).toString());
Compound xExt = term("{x}");
assertEquals(Op.SETe, xExt.op());
assertEquals(1, xExt.subs());
assertEquals("x", xExt.sub(0).toString());
Compound abInt = term("[a,b]");
assertEquals(2, abInt.subs());
assertEquals("a", abInt.sub(0).toString());
assertEquals("b", abInt.sub(1).toString());
assertEquals(abInt, term("[ a,b]"));
assertEquals(abInt, term("[a,b ]"));
assertEquals(abInt, term("[ a , b ]"));
}
use of nars.term.Compound in project narchy by automenta.
the class RelativeSignalClassifier method run.
public void run() {
float h = input();
float dMean = (float) (h - history.getMean());
double varianceThresh = history.getVariance();
history.addValue(h);
// TODO add more discretization range parmeters
int y;
Compound e;
if (dMean > varianceThresh) {
y = +1;
} else if (dMean < -varianceThresh) {
y = -1;
} else {
y = 0;
}
output.accept(y);
}
Aggregations