Search in sources :

Example 16 with Task

use of nars.Task in project narchy by automenta.

the class NarseseBaseTest method testMultiCompound.

@Test
public void testMultiCompound() throws Narsese.NarseseException {
    String tt = "((a==>b)-->(c==>d))";
    Task t = task(tt + '?');
    assertNotNull(t);
    assertEquals(Op.INH, t.op());
    assertEquals(tt, t.term().toString());
    assertEquals('?', t.punc());
    assertNull(t.truth());
    assertEquals(7, t.term().complexity());
}
Also used : Task(nars.Task) Test(org.junit.jupiter.api.Test)

Example 17 with Task

use of nars.Task in project narchy by automenta.

the class NarseseBaseTest method testTenses.

@Test
public void testTenses() throws Narsese.NarseseException {
    Task now = task("<a --> b>. :|:");
    Task f = task("<a --> b>. :/:");
    Task p = task("<a --> b>. :\\:");
    assertTrue(now.start() > p.start());
    assertTrue(now.start() < f.start());
}
Also used : Task(nars.Task) Test(org.junit.jupiter.api.Test)

Example 18 with Task

use of nars.Task in project narchy by automenta.

the class NarseseBaseTest method testBudget.

@Test
public void testBudget() throws Narsese.NarseseException {
    Task t = task("$0.70 <a ==> b>. %0.00;0.93");
    assertEquals(0.7f, t.pri(), 0.01f);
    Task u = task("$0.9 <a ==> b>. %0.00;0.93");
    assertEquals(0.9f, u.pri(), 0.01f);
}
Also used : Task(nars.Task) Test(org.junit.jupiter.api.Test)

Example 19 with Task

use of nars.Task in project narchy by automenta.

the class NarseseBaseTest method testParseCompleteEternalTask.

@Test
public void testParseCompleteEternalTask() throws Narsese.NarseseException {
    Task t = task("$0.99 (a --> b)! %0.93;0.95%");
    assertNotNull(t);
    assertEquals('!', t.punc());
    assertEquals(0.99f, t.pri(), 0.001);
    assertEquals(0.93f, t.freq(), 0.001);
    assertEquals(0.95f, t.conf(), 0.001);
}
Also used : Task(nars.Task) Test(org.junit.jupiter.api.Test)

Example 20 with Task

use of nars.Task in project narchy by automenta.

the class NarseseTest method taskParses.

// @Test
// public void testImageIndex() throws Narsese.NarseseException {
// for (char c : new char[] { '/', '\\'}) {
// {
// Compound t = term("(" + c + ",open,$1,_)");
// assertEquals("(" + c + ",open,$1,_)", t.toString());
// assertEquals("index psuedo-term should not count toward its size", 2, t.size());
// }
// 
// Compound t = term("(" + c + ",open,_,$1)");
// assertEquals("(" + c + ",open,_,$1)", t.toString());
// assertEquals("index psuedo-term should not count toward its size", 2, t.size());
// }
// }
// 
// @Test
// public void testImageExtRel0() throws Narsese.NarseseException { testImageExtRel("(a-->(/,_,y,z))", 0); }
// @Test
// public void testImageIntRel0() throws Narsese.NarseseException { testImageIntRel("((\\,_,y,z)-->a)", 0); }
// 
// @Test
// public void testImageExtRel1() throws Narsese.NarseseException { testImageExtRel("(a-->(/,x,_,z))", 1); }
// @Test
// public void testImageIntRel1() throws Narsese.NarseseException { testImageIntRel("((\\,x,_,z)-->a)", 1); }
// 
// @Test
// public void testImageExtRel2() throws Narsese.NarseseException { testImageExtRel("(a-->(/,x,y,_))", 2); }
// @Test
// public void testImageIntRel2() throws Narsese.NarseseException { testImageIntRel("((\\,x,y,_)-->a)", 2); }
// 
// private void testImageIntRel(@NotNull String imageTerm, int relationIndexExpected) throws Narsese.NarseseException {
// Compound ti = term(imageTerm);
// assertEquals(relationIndexExpected, ((Compound)ti.sub(0)).dt()  );
// assertEquals(imageTerm, ti.toString());
// }
// 
// private void testImageExtRel(@NotNull String imageTerm, int relationIndexExpected) throws Narsese.NarseseException {
// Compound ti = term(imageTerm);
// assertEquals(relationIndexExpected, ((Compound)ti.sub(1)).dt() );
// assertEquals(imageTerm, ti.toString());
// }
protected void taskParses(@NotNull String s) throws Narsese.NarseseException {
    Task t = task(s);
    assertNotNull(t);
// Task u = oldParser.parseTaskOld(s, true);
// assertNotNull(u);
// 
// assertEquals(u.getTerm() + " != " + t.getTerm(), u.getTerm(), t.getTerm());
// assertEquals("(truth) " + t.getTruth() + " != " + u.getTruth(), u.getTruth(), t.getTruth());
// //assertEquals("(creationTime) " + u.getCreationTime() + " != " + t.getCreationTime(), u.getCreationTime(), t.getCreationTime());
// assertEquals("(occurrencetime) " + u.getOccurrenceTime() + " != " + t.getOccurrenceTime(), u.getOccurrenceTime(), t.getOccurrenceTime());
// TODO budget:
// TODO punctuation:
}
Also used : Task(nars.Task)

Aggregations

Task (nars.Task)50 Term (nars.term.Term)15 NALTask (nars.task.NALTask)13 Truth (nars.truth.Truth)12 Nullable (org.jetbrains.annotations.Nullable)11 SignalTask (nars.task.signal.SignalTask)9 Test (org.junit.jupiter.api.Test)8 ITask (nars.task.ITask)6 FasterList (jcog.list.FasterList)5 NAR (nars.NAR)5 PreciseTruth (nars.truth.PreciseTruth)4 Util (jcog.Util)3 Top (jcog.sort.Top)3 Op (nars.Op)3 Param (nars.Param)3 TaskRegion (nars.task.util.TaskRegion)3 List (java.util.List)2 Map (java.util.Map)2 Random (java.util.Random)2 VLink (jcog.pri.VLink)2