Search in sources :

Example 1 with Atomic

use of nars.term.atom.Atomic in project narchy by automenta.

the class DefaultTermizer method mapStaticClassFields.

@NotNull
public static <T extends Term> Map<Atomic, T> mapStaticClassFields(@NotNull Class c, @NotNull Function<Field, T> each) {
    Field[] ff = c.getFields();
    Map<Atomic, T> t = $.newHashMap(ff.length);
    for (Field f : ff) {
        if (Modifier.isStatic(f.getModifiers())) {
            T xx = each.apply(f);
            if (xx != null) {
                t.put(Atomic.the(f.getName()), xx);
            }
        }
    }
    return t;
}
Also used : Field(java.lang.reflect.Field) INT(nars.Op.INT) Atomic(nars.term.atom.Atomic) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with Atomic

use of nars.term.atom.Atomic in project narchy by automenta.

the class NarseseBaseTest method testFloatAtom.

@Test
public void testFloatAtom() throws Narsese.NarseseException {
    // TODO test parsing to numeric atom types
    float f = 1.24f;
    String ff = Float.toString(f);
    Atomic a = term(ff);
    assertNotNull(a);
    assertEquals('"' + ff + '"', a.toString());
}
Also used : Atomic(nars.term.atom.Atomic) Test(org.junit.jupiter.api.Test)

Example 3 with Atomic

use of nars.term.atom.Atomic in project narchy by automenta.

the class ConceptIndexTest method testCommonPrefix.

public static void testCommonPrefix(boolean direction) {
    MaplikeConceptIndex i = (MaplikeConceptIndex) (NARS.shell().concepts);
    Atomic sui = Atomic.the("substituteIfUnifies");
    Atomic su = Atomic.the("substitute");
    if (direction) {
        i.get(sui, true);
        i.get(su, true);
    } else {
        // reverse
        i.get(su, true);
        i.get(sui, true);
    }
    System.out.println(i);
    i.print(System.out);
    // assertEquals(20 + 2, i.atoms.size());
    assertEquals(sui, i.concept(sui, false).term());
    assertEquals(su, i.concept(su, false).term());
    assertNotEquals(sui, i.concept(su, false).term());
}
Also used : MaplikeConceptIndex(nars.index.term.map.MaplikeConceptIndex) Atomic(nars.term.atom.Atomic)

Example 4 with Atomic

use of nars.term.atom.Atomic in project narchy by automenta.

the class UnitCompoundTest method testUnitCompound2.

@Test
public void testUnitCompound2() {
    Atomic x = Atomic.the("x");
    Term c = $.p(x);
    System.out.println(c);
    System.out.println(c.sub(0));
    Compound d = $.inh(x, Atomic.the("y"));
    System.out.println(d);
}
Also used : Atomic(nars.term.atom.Atomic) Compound(nars.term.Compound) Term(nars.term.Term) Test(org.junit.jupiter.api.Test)

Example 5 with Atomic

use of nars.term.atom.Atomic in project narchy by automenta.

the class UnitCompoundTest method testUnitCompound3.

@Test
public void testUnitCompound3() {
    Atomic x = Atomic.the("x");
    Atomic y = Atomic.the("y");
    Term c = $.func(x, y);
    System.out.println(c);
    assertEquals("(y)", c.sub(0).toString());
    assertEquals("x", c.sub(1).toString());
}
Also used : Atomic(nars.term.atom.Atomic) Term(nars.term.Term) Test(org.junit.jupiter.api.Test)

Aggregations

Atomic (nars.term.atom.Atomic)12 Test (org.junit.jupiter.api.Test)7 Op (nars.Op)3 Term (nars.term.Term)3 Compound (nars.term.Compound)2 alice.tuprolog (alice.tuprolog)1 Field (java.lang.reflect.Field)1 DynBytes (jcog.data.byt.DynBytes)1 NAR (nars.NAR)1 NARS (nars.NARS)1 INT (nars.Op.INT)1 Ellipsis (nars.derive.match.Ellipsis)1 Ellipsis.firstEllipsis (nars.derive.match.Ellipsis.firstEllipsis)1 EllipsisOneOrMore (nars.derive.match.EllipsisOneOrMore)1 MaplikeConceptIndex (nars.index.term.map.MaplikeConceptIndex)1 Atom (nars.term.atom.Atom)1 NormalizedVariable (nars.term.var.NormalizedVariable)1 NotNull (org.jetbrains.annotations.NotNull)1