use of nars.NARS in project narchy by automenta.
the class JsonTermTest method testBigJSON2.
@Test
public void testBigJSON2() {
/*
* https://eonet.sci.gsfc.nasa.gov/api/v2.1/events?limit=5&days=20&source=InciWeb&status=open
* https://worldview.earthdata.nasa.gov/config/wv.json
* */
String j = "{ \"id\": \"EONET_2797\",\n" + " \"title\": \"Snake Ridge Fire, ARIZONA\",\n" + " \"description\": \"\",\n" + " \"link\": \"http://eonet.sci.gsfc.nasa.gov/api/v2.1/events/EONET_2797\",\n" + " \"categories\": [\n" + " {\n" + " \"id\": 8,\n" + " \"title\": \"Wildfires\"\n" + " }\n" + " ] }";
NAR d = new NARS().get();
d.log();
d.believe($.inh($.fromJSON(j), "x"));
d.run(1000);
}
use of nars.NARS in project narchy by automenta.
the class JsonTermTest method testJsonArray.
@Test
public void testJsonArray() throws Narsese.NarseseException {
NAR d = new NARS().get();
d.log();
new TaskRule("(json,%1):{x(%2)}", "X(%1,%2)", d);
// d.believe( $.inh( JsonCompound.the("['a', 1, ['b', 'c']]"), $.the("(json,1)") ) );
// TaskProcess: $.50;.95$ (("a"),(1),(("b"),("c"))). %1.0;.90% {0: 1}
d.believe($.inh(JsonTerm.the("{ x: 3, y: [\"a\",4] }"), $.$("(json,2)")));
// d.believe( $.inh( JsonCompound.the("{ x: 3 }"), $.$("(json,2)") ) );
// $.15;.86$ X(3,2). %1.0;.81% {1: 1;;}
// $.50;.95$ {x(3),y(("a"),("b"))}. %1.0;.90% {0: 2}
d.run(256);
}
use of nars.NARS in project narchy by automenta.
the class SoNAR method main.
public static void main(String[] args) throws LineUnavailableException, InterruptedException, Narsese.NarseseException {
NAR n = new NARS().get();
// n.log();
n.input("a:b. :|: (--,b:c). c:d. d:e. (--,e:f). f:g. b:f. a:g?");
n.startPeriodMS(16);
SoNAR s = new SoNAR(n);
SampleDirectory d = new SampleDirectory();
d.samples("/home/me/wav/legoweltkord");
s.listen(n.conceptualize($("a")), d::byHash);
s.listen(n.conceptualize($("b")), d::byHash);
s.listen(n.conceptualize($("c")), d::byHash);
s.listen(n.conceptualize($("d")), d::byHash);
s.listen(n.conceptualize($("e")), d::byHash);
s.listen(n.conceptualize($("f")), d::byHash);
s.listen(n.conceptualize($("g")), d::byHash);
s.listen(n.conceptualize($("a:b")), d::byHash);
s.listen(n.conceptualize($("b:c")), d::byHash);
s.listen(n.conceptualize($("c:d")), d::byHash);
s.listen(n.conceptualize($("d:e")), d::byHash);
s.listen(n.conceptualize($("e:f")), d::byHash);
s.listen(n.conceptualize($("f:g")), d::byHash);
s.listen(n.conceptualize($("a:g")), d::byHash);
try {
s.audio.record("/tmp/test.raw");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
s.join();
}
use of nars.NARS in project narchy by automenta.
the class NAL6MultistepTest method testBurglarEarthquake2.
/**
* https://dtai.cs.kuleuven.be/problog/tutorial/basic/02_bayes.html
*/
@Test
public void testBurglarEarthquake2() throws Narsese.NarseseException {
// 0.7::burglary.
// 0.2::earthquake.
//
// 0.9::alarm :- burglary, earthquake.
// 0.8::alarm :- burglary, \+earthquake.
// 0.1::alarm :- \+burglary, earthquake.
//
// evidence(alarm,true).
// query(burglary).
// query(earthquake).
NAR n = new NARS().get();
// d.log();
n.input("(burglary). %0.7;0.9%", "(earthquake). %0.2;0.9%", "((&&, (burglary), (earthquake)) ==> (alarm)). %0.9;0.9%", "((&&, (burglary), (--,(earthquake))) ==> (alarm)). %0.8;0.9%", "((&&, (--,(burglary)), (earthquake)) ==> (alarm)). %0.1;0.9%", "(alarm).", "(burglary)?", "(earthquake)?");
TaskConcept burglary = null, earthquake = null;
for (int i = 0; i < 5; i++) {
// burglary.print(); earthquake.print();
// long now = d.time();
n.run(100);
burglary = (TaskConcept) n.conceptualize("(burglary)");
// burglary.print(); earthquake.print();
earthquake = (TaskConcept) n.conceptualize("(earthquake)");
System.out.println("burglary=" + n.beliefTruth(burglary, 0) + "\tearthquake=" + earthquake.beliefs().truth(Tense.ETERNAL, n));
}
// result from Probcog: earthquake=23%, burglary=99%
assertEquals(0.99f, n.beliefTruth(burglary, 0).freq(), 0.33f);
assertEquals(0.23f, n.beliefTruth(earthquake, 0).freq(), 0.1f);
}
use of nars.NARS in project narchy by automenta.
the class MathTest method testImplVarAdd1.
// @Test
// public void testAdd1() {
// Terminal t = NARS.shell();
// t.log();
// t.input("(add(1,2,?x)<->result).");
// t.next();
// }
@Test
public void testImplVarAdd1() throws Narsese.NarseseException {
Param.DEBUG = true;
NAR t = new NARS().get();
// t.log();
// t.input("i:{0,1,2,3,4}.");
// t.input("i:{0,1,2}.");
t.input("i:{1}.");
t.input("i:{2}.");
t.input("i:{4}.");
t.input("((&&,({$x} --> i),({$y} --> i)) ==> ({($x,$y),($y,$x)} --> j)).");
t.run(100);
t.input("(({(#x,#y)} --> j) ==> ({add(#x,#y)} --> i)).");
t.run(100);
// t.input("(({#x,#y} --> i) && (add(#x,#y)<->sum)).");
// t.input("(({$x,$y} --> i) ==> (add($x,$y)<->sum)).");
// t.input("(&&,({$x} --> i),({$y} --> i),({add($x,$y)}-->i)).");
// /t.input("(((#x --> i)&&(#y --> i)) ==> (add(#x,#y)<->sum)).");
// t.input("((($x --> i)&&($y --> i)) ==> (add($x,$y)<->sum)).");
// t.input("(({?x,?y} --> i) ==> (add(?x,?y)<->sum))?");
// t.input("({?x}-->i)?");
}
Aggregations