Search in sources :

Example 46 with Compound

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
}
Also used : Compound(nars.term.Compound) Test(org.junit.jupiter.api.Test)

Example 47 with Compound

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());
}
Also used : Compound(nars.term.Compound) Term(nars.term.Term) Test(org.junit.jupiter.api.Test)

Example 48 with Compound

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());
}
Also used : Compound(nars.term.Compound) Test(org.junit.jupiter.api.Test)

Example 49 with Compound

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 ]"));
}
Also used : Compound(nars.term.Compound) Test(org.junit.jupiter.api.Test)

Example 50 with Compound

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);
}
Also used : Compound(nars.term.Compound)

Aggregations

Compound (nars.term.Compound)58 Test (org.junit.jupiter.api.Test)38 Term (nars.term.Term)20 Unify (nars.term.subst.Unify)3 FasterList (jcog.list.FasterList)2 XorShift128PlusRandom (jcog.math.random.XorShift128PlusRandom)2 Op (nars.Op)2 PatternCompound (nars.derive.PatternCompound)2 PatternIndex (nars.index.term.PatternIndex)2 Atomic (nars.term.atom.Atomic)2 Variable (nars.term.var.Variable)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 alice.tuprolog (alice.tuprolog)1 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Prioritized (jcog.pri.Prioritized)1 Narsese (nars.Narsese)1