Search in sources :

Example 6 with Narsese

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();
}
Also used : Task(nars.entity.Task) Narsese(nars.io.Narsese)

Example 7 with Narsese

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;
}
Also used : BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Stamp(nars.entity.Stamp) Narsese(nars.io.Narsese) Sentence(nars.entity.Sentence)

Example 8 with Narsese

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);
    }
}
Also used : Task(nars.entity.Task) Narsese(nars.io.Narsese) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) InvalidInputException(nars.io.Narsese.InvalidInputException)

Aggregations

Narsese (nars.io.Narsese)8 Task (nars.entity.Task)5 CompoundTerm (nars.language.CompoundTerm)3 Term (nars.language.Term)3 NAR (nars.main.NAR)3 Test (org.junit.Test)3 BudgetValue (nars.entity.BudgetValue)2 Sentence (nars.entity.Sentence)2 Stamp (nars.entity.Stamp)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InvalidInputException (nars.io.Narsese.InvalidInputException)1 Inheritance (nars.language.Inheritance)1 Statement (nars.language.Statement)1