Search in sources :

Example 1 with Tense

use of nars.language.Tense in project opennars by opennars.

the class Narsese method parseTask.

/**
 * Enter a new Task in String into the memory, called from InputWindow or
 * locally.
 *
 * @param s the single-line addInput String
 * @param memory Reference to the memory
 * @param time The current time
 * @return An experienced task
 */
public Task parseTask(String s) throws InvalidInputException {
    StringBuilder buffer = new StringBuilder(Texts.escape(s));
    String budgetString = getBudgetString(buffer);
    String truthString = getTruthString(buffer);
    Tense tense = parseTense(buffer);
    String str = buffer.toString().trim();
    int last = str.length() - 1;
    char punc = str.charAt(last);
    Stamp stamp = new Stamp(-1, /* if -1, will be set right before the Task is input */
    tense, memory.newStampSerial(), Parameters.DURATION);
    TruthValue truth = parseTruth(truthString, punc);
    Term content = parseTerm(str.substring(0, last));
    if (content == null)
        throw new InvalidInputException("Content term missing");
    Sentence sentence = new Sentence(content, punc, truth, stamp);
    // if ((content instanceof Conjunction) && Variable.containVarDep(content.getName())) {
    // sentence.setRevisible(false);
    // }
    BudgetValue budget = parseBudget(budgetString, punc, truth);
    Task task = new Task(sentence, budget, true);
    return task;
}
Also used : Tense(nars.language.Tense) BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Stamp(nars.entity.Stamp) TruthValue(nars.entity.TruthValue) Term(nars.language.Term) Sentence(nars.entity.Sentence)

Aggregations

BudgetValue (nars.entity.BudgetValue)1 Sentence (nars.entity.Sentence)1 Stamp (nars.entity.Stamp)1 Task (nars.entity.Task)1 TruthValue (nars.entity.TruthValue)1 Tense (nars.language.Tense)1 Term (nars.language.Term)1