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;
}
Aggregations