Search in sources :

Example 6 with Concept

use of nars.concept.Concept in project narchy by automenta.

the class LinkageTest method ProperlyLinkedTest.

void ProperlyLinkedTest(@NotNull String premise1, @NotNull String premise2) throws Exception {
    test.requireConditions = false;
    TestNAR tester = test;
    // .en("If robin is a type of bird then robin can fly.");
    tester.believe(premise1);
    // .en("Robin is a type of bird.");
    tester.believe(premise2);
    tester.run(runCycles, false);
    Concept ret = tester.nar.conceptualize(premise1);
    assertTrue(isPassed2(premise2, ret), ret + " termlinks contains " + premise2);
    Concept ret2 = tester.nar.conceptualize(premise2);
    assertTrue(isPassed2(premise1, ret2), ret2 + " termlinks contains " + premise1);
}
Also used : Concept(nars.concept.Concept) TestNAR(nars.test.TestNAR)

Example 7 with Concept

use of nars.concept.Concept in project narchy by automenta.

the class LinkageTest method testConceptFormed.

public void testConceptFormed(@NotNull String s) throws Exception {
    test.requireConditions = false;
    TestNAR tester = test;
    tester.believe(s, 1.0f, 0.9f);
    tester.nar.run(10);
    Concept ret = tester.nar.conceptualize(s);
    assertNotNull(ret, "Failed to create a concept for " + s);
}
Also used : Concept(nars.concept.Concept) TestNAR(nars.test.TestNAR)

Example 8 with Concept

use of nars.concept.Concept in project narchy by automenta.

the class LinkageTest method links.

public boolean links(@NotNull String premise1, String premise2, @NotNull TestNAR tester) throws Narsese.NarseseException {
    Concept ret = tester.nar.conceptualize(premise1);
    boolean passed = false;
    if (ret != null) {
        for (PriReference<Term> entry : ret.termlinks()) {
            Term et1 = entry.get().term();
            if (et1.toString().equals(premise2)) {
                passed = true;
                break;
            }
            if (!(et1 instanceof Variable)) {
                Concept Wc = tester.nar.concept(et1);
                if (Wc != null) {
                    for (PriReference<Term> entry2 : Wc.termlinks()) {
                        Term et2 = entry2.get().term();
                        if (et2.toString().equals(premise2)) {
                            passed = true;
                            break;
                        }
                        Concept Wc2 = tester.nar.concept(et2);
                        if (Wc2 != null) {
                            for (PriReference<Term> entry3 : Wc2.termlinks()) {
                                Term et3 = entry3.get().term();
                                if (et3.toString().equals(premise2)) {
                                    passed = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        /*if (w.toString().equals(premise2)) {
                    passed = true;
                }*/
        }
    }
    return passed;
}
Also used : Concept(nars.concept.Concept) Variable(nars.term.var.Variable) Term(nars.term.Term)

Example 9 with Concept

use of nars.concept.Concept in project narchy by automenta.

the class OperatorTest method testThe.

/**
 * tests Builtin.System and evaluating a term input as a command
 */
@Test
public void testThe() throws Narsese.NarseseException {
    NAR n = NARS.tmp();
    @Nullable Concept statusFunctor = n.concept($.the("the"));
    statusFunctor.print();
    StringBuilder b = new StringBuilder();
    n.log(b);
    n.input("the(sys)");
    String s = b.toString();
    assertTrue(s.contains("→("), () -> s);
}
Also used : Concept(nars.concept.Concept) TestNAR(nars.test.TestNAR) Nullable(org.jetbrains.annotations.Nullable) Test(org.junit.jupiter.api.Test)

Example 10 with Concept

use of nars.concept.Concept in project narchy by automenta.

the class DynamicTruthBeliefTableTest method testDynamicConjConceptWithNegations.

@Test
public void testDynamicConjConceptWithNegations() throws Narsese.NarseseException {
    NAR n = NARS.tmp();
    for (String s : new String[] { "((y-->t) &&+1 (t-->happy))", "(--(y-->t) &&+1 (t-->happy))", "((y-->t) &&+1 --(t-->happy))", "(--(y-->t) &&+1 --(t-->happy))" }) {
        Concept c = n.conceptualize($.$(s));
        assertTrue(c.beliefs() instanceof DynamicTruthBeliefTable);
        assertTrue(c.goals() instanceof DynamicTruthBeliefTable);
    }
}
Also used : TaskConcept(nars.concept.TaskConcept) Concept(nars.concept.Concept) Test(org.junit.jupiter.api.Test)

Aggregations

Concept (nars.concept.Concept)47 TaskConcept (nars.concept.TaskConcept)19 Term (nars.term.Term)19 Test (org.junit.jupiter.api.Test)15 Nullable (org.jetbrains.annotations.Nullable)11 Truth (nars.truth.Truth)9 NAR (nars.NAR)6 Termed (nars.term.Termed)6 FasterList (jcog.list.FasterList)4 PermanentConcept (nars.concept.PermanentConcept)4 BeliefTable (nars.table.BeliefTable)4 TestNAR (nars.test.TestNAR)4 Util (jcog.Util)3 PriReference (jcog.pri.PriReference)3 GL2 (com.jogamp.opengl.GL2)2 java.io (java.io)2 java.util (java.util)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Op (nars.Op)2 CauseLink (nars.link.CauseLink)2