本文整理汇总了Java中nars.entity.Task类的典型用法代码示例。如果您正苦于以下问题:Java Task类的具体用法?Java Task怎么用?Java Task使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Task类属于nars.entity包,在下文中一共展示了Task类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: textInputLine
import nars.entity.Task; //导入依赖的package包/类
/**
* To process a line of input text
* @param text
*/
public void textInputLine(String text) {
if (text.isEmpty()) {
return;
}
char c = text.charAt(0);
if (c == Symbols.RESET_MARK) {
reset();
memory.getExportStrings().add(text);
} else if (c == Symbols.COMMENT_MARK) {
return;
} else {
// read NARS language or an integer : TODO duplicated code
try {
int i = Integer.parseInt(text);
walk(i);
} catch (NumberFormatException e) {
Task task = StringParser.parseExperience(new StringBuffer(text), memory, clock);
if (task != null) {
memory.inputTask(task);
}
}
}
}
示例2: processNewTask
import nars.entity.Task; //导入依赖的package包/类
/**
* Process the newTasks accumulated in the previous workCycle, accept input ones
* and those that corresponding to existing concepts, plus one from the buffer.
*/
private void processNewTask() {
Task task;
int counter = newTasks.size(); // don't include new tasks produced in the current workCycle
while (counter-- > 0) {
task = newTasks.remove(0);
if (task.isInput() || (termToConcept(task.getContent()) != null)) { // new input or existing concept
immediateProcess(task);
} else {
Sentence s = task.getSentence();
if (s.isJudgment()) {
double d = s.getTruth().getExpectation();
if (d > Parameters.DEFAULT_CREATION_EXPECTATION) {
novelTasks.putIn(task); // new concept formation
} else {
recorder.append("!!! Neglected: " + task + "\n");
}
}
}
}
}
示例3: activatedTask
import nars.entity.Task; //导入依赖的package包/类
/**
* Activated task called in MatchingRules.trySolution and
* Concept.processGoal
*
* @param budget The budget value of the new Task
* @param sentence The content of the new Task
* @param candidateBelief The belief to be used in future inference, for
* forward/backward correspondence
*/
public void activatedTask(final BudgetValue budget, final Sentence sentence, final Sentence candidateBelief) {
final Task task = new Task(sentence, budget, currentTask, sentence, candidateBelief);
if (recorder.isActive()) {
recorder.append("!!! Activated: " + task.toString() + "\n");
}
if (sentence.isQuestion()) {
final float s = task.getBudget().summary();
// float minSilent = reasoner.getMainWindow().silentW.value() / 100.0f;
final float minSilent = reasoner.param.getSilenceLevel() / 100.0f;
if (s > minSilent) { // only report significant derived Tasks
reasoner.output(OUT.class, task.getSentence());
}
}
newTasks.add(task);
}
示例4: processNewTask
import nars.entity.Task; //导入依赖的package包/类
/**
* Process the newTasks accumulated in the previous workCycle, accept input
* ones and those that corresponding to existing concepts, plus one from the
* buffer.
*/
private void processNewTask() {
// don't include new tasks produced in the current workCycle
int counter = newTasks.size();
while (counter-- > 0) {
final Task task = newTasks.removeFirst();
if (task.isInput() || (termToConcept(task.getContent()) != null)) {
// new input or existing concept
immediateProcess(task);
} else {
final Sentence s = task.getSentence();
if (s.isJudgment()) {
final double exp = s.getTruth().getExpectation();
if (exp > Parameters.DEFAULT_CREATION_EXPECTATION) {
novelTasks.putIn(task); // new concept formation
} else {
if (recorder.isActive()) {
recorder.append("!!! Neglected: " + task + "\n");
}
}
}
}
}
}
示例5: immediateProcess
import nars.entity.Task; //导入依赖的package包/类
/**
* Immediate processing of a new task, in constant time Local processing, in
* one concept only
*
* @param task the task to be accepted
*/
private void immediateProcess(final Task task) {
currentTask = task; // one of the two places where this variable is set
if (recorder.isActive()) {
recorder.append("!!! Insert: " + task + "\n");
}
currentTerm = task.getContent();
currentConcept = getConcept(currentTerm);
if (currentConcept != null) {
activateConcept(currentConcept, task.getBudget());
currentConcept.directProcess(task);
}
}
示例6: parseNarsese
import nars.entity.Task; //导入依赖的package包/类
/**
* Parse a line of input experience
* <p>
* called from ExperienceIO.loadLine
*
* @param buffer The line to be parsed
* @param memory Reference to the memory
* @param time The current time
* @return An experienced task
*/
public static Task parseNarsese(StringBuffer buffer, Memory memory, long time) throws InvalidInputException {
int i = buffer.indexOf(PREFIX_MARK + "");
if (i > 0) {
String prefix = buffer.substring(0, i).trim();
switch (prefix) {
case OUTPUT_LINE:
return null;
case INPUT_LINE:
buffer.delete(0, i + 1);
break;
}
}
char c = buffer.charAt(buffer.length() - 1);
if (c == STAMP_CLOSER) {
int j = buffer.lastIndexOf(STAMP_OPENER + "");
buffer.delete(j - 1, buffer.length());
}
return parseTask(buffer.toString().trim(), memory, time);
}
示例7: Memory
import nars.entity.Task; //导入依赖的package包/类
/**
* Create a new memory
* <p>
* Called in Reasoner.reset only
* @param reasoner
*/
public Memory(ReasonerBatch reasoner) {
this.reasoner = reasoner;
recorder = new NullInferenceRecorder();
concepts = new ConceptBag(this);
novelTasks = new NovelTaskBag(this);
newTasks = new ArrayList<Task>();
exportStrings = new ArrayList<String>();
}
示例8: inputTask
import nars.entity.Task; //导入依赖的package包/类
/**
* Input task processing. Invoked by the outside or inside environment.
* Outside: StringParser (input); Inside: Operator (feedback).
* Input tasks with low priority are ignored, and the others are put into task buffer.
* @param task The input task
*/
public void inputTask(Task task) {
if (task.getBudget().aboveThreshold()) {
recorder.append("!!! Perceived: " + task + "\n");
report(task.getSentence(), true); // report input
newTasks.add(task); // wait to be processed in the next workCycle
} else {
recorder.append("!!! Neglected: " + task + "\n");
}
}
示例9: activatedTask
import nars.entity.Task; //导入依赖的package包/类
/**
* Activated task called in MatchingRules.trySolution and Concept.processGoal
* @param budget The budget value of the new Task
* @param sentence The content of the new Task
* @param candidateBelief The belief to be used in future inference, for forward/backward correspondence
*/
public void activatedTask(BudgetValue budget, Sentence sentence, Sentence candidateBelief) {
Task task = new Task(sentence, budget, currentTask, sentence, candidateBelief);
recorder.append("!!! Activated: " + task.toString() + "\n");
if (sentence.isQuestion()) {
float s = task.getBudget().summary();
// float minSilent = reasoner.getMainWindow().silentW.value() / 100.0f;
float minSilent = reasoner.getSilenceValue().get() / 100.0f;
if (s > minSilent) { // only report significant derived Tasks
report(task.getSentence(), false);
}
}
newTasks.add(task);
}
示例10: derivedTask
import nars.entity.Task; //导入依赖的package包/类
/**
* Derived task comes from the inference rules.
* @param task the derived task
*/
private void derivedTask(Task task) {
if (task.getBudget().aboveThreshold()) {
recorder.append("!!! Derived: " + task + "\n");
float budget = task.getBudget().summary();
// float minSilent = reasoner.getMainWindow().silentW.value() / 100.0f;
float minSilent = reasoner.getSilenceValue().get() / 100.0f;
if (budget > minSilent) { // only report significant derived Tasks
report(task.getSentence(), false);
}
newTasks.add(task);
} else {
recorder.append("!!! Ignored: " + task + "\n");
}
}
示例11: doublePremiseTask
import nars.entity.Task; //导入依赖的package包/类
/**
* Shared final operations by all double-premise rules, called from the rules except StructuralRules
* @param newContent The content of the sentence in task
* @param newTruth The truth value of the sentence in task
* @param newBudget The budget value in task
*/
public void doublePremiseTask(Term newContent, TruthValue newTruth, BudgetValue newBudget) {
if (newContent != null) {
Sentence newSentence = new Sentence(newContent, currentTask.getSentence().getPunctuation(), newTruth, newStamp);
Task newTask = new Task(newSentence, newBudget, currentTask, currentBelief);
derivedTask(newTask);
}
}
示例12: processNovelTask
import nars.entity.Task; //导入依赖的package包/类
/**
* Select a novel task to process.
*/
private void processNovelTask() {
Task task = novelTasks.takeOut(); // select a task from novelTasks
if (task != null) {
immediateProcess(task);
}
}
示例13: immediateProcess
import nars.entity.Task; //导入依赖的package包/类
/**
* Immediate processing of a new task, in constant time
* Local processing, in one concept only
* @param task the task to be accepted
*/
private void immediateProcess(Task task) {
currentTask = task; // one of the two places where this variable is set
recorder.append("!!! Insert: " + task + "\n");
currentTerm = task.getContent();
currentConcept = getConcept(currentTerm);
if (currentConcept != null) {
currentConcept.directProcess(task);
}
}
示例14: inputTask
import nars.entity.Task; //导入依赖的package包/类
/**
* Input task processing. Invoked by the outside or inside environment.
* Outside: StringParser (input); Inside: Operator (feedback). Input tasks
* with low priority are ignored, and the others are put into task buffer.
*
* @param task The input task
*/
public void inputTask(final Task task) {
if (task.getBudget().aboveThreshold()) {
if (recorder.isActive()) {
recorder.append("!!! Perceived: " + task + "\n");
}
newTasks.add(task); // wait to be processed in the next workCycle
} else {
if (recorder.isActive()) {
recorder.append("!!! Neglected: " + task + "\n");
}
}
}
示例15: processNovelTask
import nars.entity.Task; //导入依赖的package包/类
/**
* Select a novel task to process.
*/
private void processNovelTask() {
final Task task = novelTasks.takeOut(); // select a task from novelTasks
if (task != null) {
immediateProcess(task);
}
}