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;
}
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());
}
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());
}
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);
}
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());
}
Aggregations