Search in sources :

Example 56 with NAR

use of nars.NAR in project narchy by automenta.

the class NQuadsRDFTest method testSchema1.

@Disabled
@Test
public void testSchema1() throws Exception {
    final NAR n = NARS.tmp();
    File output = new File("/tmp/onto.nal");
    PrintStream pout = new PrintStream(new BufferedOutputStream(new FileOutputStream(output), 512 * 1024));
    n.input(NQuadsRDF.stream(n, new File(// "/tmp/all-layers.nq"
    "/home/me/Downloads/nquad")).peek(t -> {
        pout.println(t.term().toString() + t.punc());
    // t.budget(0, 0.5f);
    }));
    pout.close();
    // n.forEachActiveConcept(c -> {
    // c.print();
    // });
    n.run(1);
    // n.focus.active.clear();
    n.log();
    n.input("$0.9$ (Bacteria <-> Pharmacy)?");
    // Param.DEBUG = true;
    n.run(128);
// n.index.forEach(c -> {
// System.out.println(c);
// });
}
Also used : Param(nars.Param) Test(org.junit.jupiter.api.Test) PrintStream(java.io.PrintStream) NARS(nars.NARS) NAR(nars.NAR) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) FileOutputStream(java.io.FileOutputStream) Disabled(org.junit.jupiter.api.Disabled) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) PrintStream(java.io.PrintStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) NAR(nars.NAR) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 57 with NAR

use of nars.NAR in project narchy by automenta.

the class NQuadsRDFTest method testSchema2.

@Disabled
@Test
public void testSchema2() throws Exception {
    final NAR n = NARS.tmp();
    Param.DEBUG = true;
    for (String input : new String[] { "/home/me/d/finance/money.orig.n3", "/home/me/d/finance/finance.orig.n3" }) {
        File output = new File(input + ".nal");
        PrintStream pout = new PrintStream(new BufferedOutputStream(new FileOutputStream(output), 512 * 1024));
        NQuadsRDF.stream(n, new File(input)).peek(t -> {
            t.pri(n.priDefault(t.punc()) / 10f);
            pout.println(t + ".");
        }).forEach(x -> {
            n.input(x);
            // allow process
            n.run(1);
        });
        pout.close();
    }
    // n.forEachActiveConcept(c -> {
    // c.print();
    // });
    // n.run(512);
    /*n.concepts().forEach(Concept::print);
        n.concept($.the("Buyer")).print();*/
    n.clear();
    n.log();
    n.run(1);
    n.input("({I}-->PhysicalPerson).");
    n.run(1);
    n.input("({I}-->Seller).");
    n.run(1);
    n.input("({I}-->ExternalRisk).");
    n.run(1);
    n.input("({I}-->Service).");
    n.run(1);
    n.input("({I}-->FinancialInstrument).");
    n.run(1);
    n.input("({I}-->NonResidentCapitalOwner)!");
    n.run(1);
    n.input("isReceiverOfPhysicalValue(I,#1)!");
    n.run(1);
    n.input("--isReceiverOfPhysicalValue(#1,I)!");
    n.run(1);
    n.input("isReceiverOfObligationValue(I,#1)!");
    n.run(1);
    n.input("--isReceiverOfObligationValue(#1,I)!");
    n.run(1);
    n.input("$0.99 (I<->?x)?");
    n.run(2512);
}
Also used : Param(nars.Param) Test(org.junit.jupiter.api.Test) PrintStream(java.io.PrintStream) NARS(nars.NARS) NAR(nars.NAR) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) FileOutputStream(java.io.FileOutputStream) Disabled(org.junit.jupiter.api.Disabled) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) PrintStream(java.io.PrintStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) NAR(nars.NAR) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 58 with NAR

use of nars.NAR in project narchy by automenta.

the class PrologCoreTest method testPrologCoreQuestionTruthAnswer.

@Test
public void testPrologCoreQuestionTruthAnswer() throws Narsese.NarseseException {
    NAR n = NARS.tmp();
    PrologCore p = new PrologCore(n);
    n.input("a:b.");
    n.input("a:c.");
    n.input("(--, c:d).");
    n.run(1);
    n.input("a:b?");
    // expect true
    n.run(1);
    n.input("c:d?");
    // expect false
    n.run(1);
    n.input("a:?x?");
    // expect true with 2 answers
    n.run(1);
}
Also used : PrologCore(nars.op.prolog.PrologCore) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Example 59 with NAR

use of nars.NAR in project narchy by automenta.

the class PrologCoreTest method testConjunction3.

@Test
public void testConjunction3() throws Narsese.NarseseException {
    NAR n = NARS.tmp();
    PrologCore p = new PrologCore(n);
    n.input("(&&,a,b,c).");
    n.run(1);
    assertTrue(p.isTrue("'&&'(a,b,c)."));
    assertTrue(p.isTrue("a,b,c."));
// assertTrue(p.isTrue("','(a,','(b,c))."));
}
Also used : PrologCore(nars.op.prolog.PrologCore) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Example 60 with NAR

use of nars.NAR in project narchy by automenta.

the class PrologCoreTest method testPrologCoreBeliefAssertion.

@Test
public void testPrologCoreBeliefAssertion() throws Narsese.NarseseException {
    NAR n = NARS.tmp();
    PrologCore p = new PrologCore(n);
    n.input("a:b.");
    n.input("(--, c:d).");
    n.run(1);
    assertTrue(p.isTrue("'-->'(b,a)."));
    assertFalse(p.isTrue("'-->'(a,b)."));
    assertTrue(p.isTrue("'--'('-->'(d,c))."));
    assertFalse(p.isTrue("'-->'(d,c)."));
}
Also used : PrologCore(nars.op.prolog.PrologCore) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Aggregations

NAR (nars.NAR)124 Test (org.junit.jupiter.api.Test)92 NARS (nars.NARS)23 Term (nars.term.Term)20 Truth (nars.truth.Truth)18 TestNAR (nars.test.TestNAR)16 BeliefTable (nars.table.BeliefTable)10 Disabled (org.junit.jupiter.api.Disabled)9 PrologCore (nars.op.prolog.PrologCore)8 Nullable (org.jetbrains.annotations.Nullable)8 Task (nars.Task)7 Concept (nars.concept.Concept)6 Param (nars.Param)5 Termed (nars.term.Termed)5 List (java.util.List)4 FasterList (jcog.list.FasterList)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 nars.$ (nars.$)3 ITask (nars.task.ITask)3 NALTest (nars.util.NALTest)3