use of nars.term.Compound in project narchy by automenta.
the class PremiseRuleTest method printTermRecursive.
@Test
public void printTermRecursive() throws Narsese.NarseseException {
// PremiseRule r = (PremiseRule) p.term(onlyRule);
// return rule(
// r
// );
Compound y = (Compound) parse("(S --> P), --%S |- (P --> S), (Belief:Conversion, Info:SeldomUseful)").term();
Terms.printRecursive(System.out, y);
}
use of nars.term.Compound in project narchy by automenta.
the class NLPGen method train.
private void train(String natural, Task t) {
Compound pattern = (Compound) (index.get(t.term(), true).term());
rules.add((tt, freq, conf, tense) -> {
if (timeMatch(t, tense)) {
if (Math.abs(t.freq() - freq) < 0.33f) {
if (Math.abs(t.conf() - conf) < 0.33f) {
final String[] result = { null };
Unify u = new Unify(VAR_PATTERN, terminal.random(), Param.UnificationStackMax, terminal.matchTTLmean.intValue()) {
@Override
public void tryMatch() {
final String[] r = { natural };
xy.forEach((x, y) -> {
String var = x.toString();
if (!var.startsWith("%"))
return;
// HACK conversion between normalized pattern vars and the vars used in the input pattern
var = String.valueOf(((char) (var.charAt(1) - '1' + 'A')));
r[0] = r[0].replace(var, y.toString());
});
result[0] = r[0];
}
};
u.unify(pattern, tt, true);
if (result[0] != null)
return result[0];
}
}
}
return null;
});
}
use of nars.term.Compound in project narchy by automenta.
the class UnitCompoundTest method assertEqual.
static void assertEqual(Op o, Atomic x, Compound u) {
Compound g = CachedCompound.the(o, new UnitSubterm(x));
assertEquals(g.hashCode(), u.hashCode());
assertEquals(g.hashCodeSubterms(), u.hashCodeSubterms());
assertEquals(u, g);
assertEquals(g, u);
assertEquals(0, u.compareTo(g));
assertEquals(0, g.compareTo(u));
assertEquals(g.toString(), u.toString());
assertTrue(Arrays.equals(TermKey.termByVolume(g).array(), TermKey.termByVolume(u).array()));
assertTrue(Arrays.equals(IO.termToBytes(g), IO.termToBytes(u)));
}
Aggregations