use of nars.io.Narsese in project opennars by opennars.
the class ConceptMonitor method stringToTerm.
public static Term stringToTerm(NAR nar, String s) {
Narsese narsese = new Narsese(nar.memory);
Task ret;
try {
ret = narsese.parseTask(s + Symbols.JUDGMENT_MARK);
} catch (Narsese.InvalidInputException ex) {
return null;
}
if (ret == null) {
return null;
}
return ret.getTerm();
}
use of nars.io.Narsese in project opennars by opennars.
the class NAR method askNow.
public NAR askNow(String termString, AnswerHandler answered) throws InvalidInputException {
Task t;
addInput(t = new Task(new Sentence(new Narsese(this).parseTerm(termString), Symbols.QUESTION_MARK, null, new Stamp(memory, Tense.Present)), new BudgetValue(Parameters.DEFAULT_QUESTION_PRIORITY, Parameters.DEFAULT_QUESTION_DURABILITY, 1), true));
if (answered != null) {
answered.start(t, this);
}
return this;
}
use of nars.io.Narsese in project opennars by opennars.
the class NAR method addInput.
public void addInput(final String text) {
Narsese narsese = new Narsese(this);
if (addMultiLineInput(text)) {
return;
}
try {
if (addCommand(text)) {
return;
}
Task t = narsese.parseTask(text.trim());
this.memory.inputTask(t);
} catch (Exception ex) {
// Logger.getLogger(NAR.class.getName()).log(Level.SEVERE, null, ex);
}
}
Aggregations