當前位置: 首頁>>代碼示例>>Java>>正文


Java Sentence類代碼示例

本文整理匯總了Java中nars.entity.Sentence的典型用法代碼示例。如果您正苦於以下問題:Java Sentence類的具體用法?Java Sentence怎麽用?Java Sentence使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Sentence類屬於nars.entity包,在下文中一共展示了Sentence類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processNewTask

import nars.entity.Sentence; //導入依賴的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");
                }
            }
        }
    }
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:25,代碼來源:Memory.java

示例2: setup

import nars.entity.Sentence; //導入依賴的package包/類
@Override
public void setup() {  
    //size((int) sx, (int) sy);
    
    hsim.obj = new ArrayList<Obj>();
    E = new ArrayList<link>();
    E2 = new ArrayList<link>();
    Sent_s = new ArrayList<Sentence>(); //derivation chain
    Sent_i = new ArrayList<Integer>(); //derivation chain

    try {
        Thread.sleep(200);
    } catch (InterruptedException ex) {
    }
    background(0);
    
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:18,代碼來源:MemoryView.java

示例3: output

import nars.entity.Sentence; //導入依賴的package包/類
@Override
public void output(Class channel, Object o) {
    if (o instanceof Sentence) {
        Sentence s = (Sentence)o;
        
        float freq = -1;
        float conf = -1;
        TruthValue truth = s.getTruth();
        if (truth!=null) {
            freq = truth.getFrequency();
            conf = truth.getConfidence();
        }
        
        //TODO use table sort instead of formatting numbers with leading '0's
        data.addRow(new Object[] {
            s,
            String.format("%08d",  nar.getTime()),
            s.getPunctuation(),
            freq == -1 ? "" : freq,
            conf == -1 ? "" : conf,
            String.format("%03d",  s.getContent().getComplexity())     
        });
    }
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:25,代碼來源:SentenceTablePanel.java

示例4: activatedTask

import nars.entity.Sentence; //導入依賴的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);
    }
 
開發者ID:automenta,項目名稱:opennars,代碼行數:25,代碼來源:Memory.java

示例5: processNewTask

import nars.entity.Sentence; //導入依賴的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");
                    }
                }
            }
        }
    }
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:30,代碼來源:Memory.java

示例6: parseOutput

import nars.entity.Sentence; //導入依賴的package包/類
public static Sentence parseOutput(String s) {
    Term content = null;
    char punc = 0;
    TruthValue truth = null;
    
    try {
        StringBuffer buffer = new StringBuffer(s);
        //String budgetString = getBudgetString(buffer);
        String truthString = getTruthString(buffer);
        String str = buffer.toString().trim();
        int last = str.length() - 1;
        punc = str.charAt(last);
        //Stamp stamp = new Stamp(time);
        truth = parseTruth(truthString, punc);


        /*Term content = parseTerm(str.substring(0, last), memory);
        if (content == null) throw new InvalidInputException("Content term missing");*/
    }
    catch (InvalidInputException e) {
        System.err.println("TextInput.parseOutput: " + s + " : " + e.toString());
    }
    return new Sentence(content, punc, truth, null);        
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:25,代碼來源:TextInput.java

示例7: activatedTask

import nars.entity.Sentence; //導入依賴的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);
    }
 
開發者ID:automenta,項目名稱:opennars,代碼行數:20,代碼來源:Memory.java

示例8: doublePremiseTask

import nars.entity.Sentence; //導入依賴的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);
    }
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:14,代碼來源:Memory.java

示例9: report

import nars.entity.Sentence; //導入依賴的package包/類
/**
     * Display input/output sentence in the output channels.
     * The only place to add Objects into exportStrings. Currently only Strings
     * are added, though in the future there can be outgoing Tasks;
     * also if exportStrings is empty display the current value of timer
     * ( exportStrings is emptied in {@link ReasonerBatch#doTick()} - TODO fragile mechanism) 
     * @param sentence the sentence to be displayed
     * @param input whether the task is input
     */
    public void report(Sentence sentence, boolean input) {
    	if (ReasonerBatch.DEBUG) {
    		System.out.println("// report( clock " + reasoner.getTime()
    				+ ", input " + input
    				+ ", timer " + reasoner.getTimer()
    				+ ", Sentence " + sentence
    				+ ", exportStrings " + exportStrings
    				);
    		System.out.flush();
    	}
        if (exportStrings.isEmpty()) {
//          long timer = reasoner.getMainWindow().updateTimer();
            long timer = reasoner.updateTimer();
            if (timer > 0) {
                exportStrings.add(String.valueOf(timer));
            }
        }

        String s;
        if (input) {
            s = "  IN: ";
        } else {
            s = " OUT: ";
        }
        s += sentence.toStringBrief();
        exportStrings.add(s);
    }
 
開發者ID:automenta,項目名稱:opennars,代碼行數:37,代碼來源:Memory.java

示例10: getVertexSize

import nars.entity.Sentence; //導入依賴的package包/類
public float getVertexSize(Object o) {
    if (o instanceof Sentence) {
        Sentence s = (Sentence)o;
        return (float)(nodeSize * (0.25 + 0.75 * s.getTruth().getConfidence()));
    }
    else if (o instanceof Term) {
        Term t = (Term)o;
        return (float)(Math.log(1+1 + t.getComplexity()) * nodeSize);
    }
    return nodeSize;
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:12,代碼來源:ProcessingGraphPanel.java

示例11: getVertexAlpha

import nars.entity.Sentence; //導入依賴的package包/類
public float getVertexAlpha(Object o) {
    if (o instanceof Sentence) {
        Sentence s = (Sentence)o;
        return (float)((0.25 + 0.75 * s.getTruth().getConfidence()));
    }        
    return 1.0f;
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:8,代碼來源:ProcessingGraphPanel.java

示例12: getSelectedRows

import nars.entity.Sentence; //導入依賴的package包/類
private List<Sentence> getSelectedRows() {
    int[] selectedRows = t.getSelectedRows();
    List<Sentence> l = new ArrayList(selectedRows.length);
    for (int i : selectedRows) {            
        int selectedRow = t.convertRowIndexToModel(i);            
        l.add((Sentence)data.getValueAt(selectedRow, 0));
    }
    return l;        
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:10,代碼來源:SentenceTablePanel.java

示例13: onConcept

import nars.entity.Sentence; //導入依賴的package包/類
@Override
public void onConcept(NARGraph g, Concept c) {

    final Term term = c.getTerm();
    addTerm(g, term);

    if (includeBeliefs) {
        for (final Sentence kb : c.beliefs) {
            sentenceTerms.put(kb, term);
            //TODO check if kb.getContent() is never distinct from c.getTerm()
            addTerm(g, kb.getContent());
            
            g.addVertex(kb);
            g.addEdge(term, kb, new TermBelief());
        }
    }
    
    if (includeQuestions) {
        for (final Task q : c.getQuestions()) {
            addTerm(g, q.getContent());
            
            //TODO q.getParentBelief()
            //TODO q.getParentTask()
            
                    
            g.addVertex(q);                    
            g.addEdge(term, q, new TermQuestion());
        }
    }
    
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:32,代碼來源:NARGraph.java

示例14: parseOutput

import nars.entity.Sentence; //導入依賴的package包/類
public Sentence parseOutput(String o) {
    //getTruthString doesnt work yet because it gets confused when Stamp is at the end of the string. either remove that first or make getTruthString aware of that
    return TextInput.parseOutput(o);
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:5,代碼來源:TestUtil.java

示例15: run

import nars.entity.Sentence; //導入依賴的package包/類
@Override
public void run() {
    if (nextOutput.size() > 0) {

        //limitBuffer(nextOutput.length());
        limitBuffer(128);

        for (Object o : nextOutput) {
            if ((o instanceof String) || (o instanceof Character))
                print(Color.BLACK, 1.0f, o.toString(), false);
            else if (o instanceof Sentence) {
                Sentence s = (Sentence)o;
                
                float conf = 0.5f, freq = 0.5f;
                if (s.getTruth() != null) {
                    conf = s.getTruth().getConfidence();
                    freq = s.getTruth().getFrequency();                            
                }
                
                float contentSize = 1f; //0.75f+conf;
                
                Color contentColor = Color.getHSBColor(0.5f + (freq-0.5f)/2f, 1.0f, 0.05f + 0.5f - conf/4f);                        
                print(contentColor, contentSize, s.getContent().toString() + s.getPunctuation(), s.isQuestion());
                
                if (s.getTruth()!=null) {
                    Color truthColor = Color.getHSBColor(freq, 0, 0.25f - conf/4f);
                    print(truthColor, contentSize, s.getTruth().toString(), false);
                }
                if (s.getStamp()!=null) {
                    Color stampColor = Color.GRAY;
                    print(stampColor, contentSize, s.getStamp().toString(), false);
                }
            }
            else {
                print(Color.BLACK, 1.0f, o.toString(), false);
            }
        }

        nextOutput.clear();
    }
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:42,代碼來源:OutputLogPanel.java


注:本文中的nars.entity.Sentence類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。