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


Java Symbols類代碼示例

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


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

示例1: setKey

import nars.io.Symbols; //導入依賴的package包/類
/**
 * Set the key of the link
 */    
protected final void setKey() {
    final String at1, at2;
    if ((type % 2) == 1) {  // to component
        at1 = Symbols.TO_COMPONENT_1;
        at2 = Symbols.TO_COMPONENT_2;
    } else {                // to compound
        at1 = Symbols.TO_COMPOUND_1;
        at2 = Symbols.TO_COMPOUND_2;
    }
    
    final StringBuffer sb = new StringBuffer(16).append(at1).append('T').append(type);
    if (index != null) {
        for (int i = 0; i < index.length; i++) {
            sb.append('-').append((index[i] + 1));
        }
    }
    sb.append(at2);
    
    if (target != null) {
        sb.append(target);
    }
    key = sb.toString();
}
 
開發者ID:opennars,項目名稱:pei,代碼行數:27,代碼來源:TermLink.java

示例2: make

import nars.io.Symbols; //導入依賴的package包/類
/**
 * Try to make a new ImageExt. Called by StringParser.
 * @return the Term generated from the arguments
 * @param argList The list of components
 * @param memory Reference to the memory
 */
public static Term make(ArrayList<Term> argList, Memory memory) {
    if (argList.size() < 2) {
        return null;
    }
    Term relation = argList.get(0);
    ArrayList<Term> argument = new ArrayList<Term>();
    int index = 0;
    for (int j = 1; j < argList.size(); j++) {
        if (argList.get(j).getName().charAt(0) == Symbols.IMAGE_PLACE_HOLDER) {
            index = j - 1;
            argument.add(relation);
        } else {
            argument.add(argList.get(j));
        }
    }
    return make(argument, (short) index, memory);
}
 
開發者ID:opennars,項目名稱:pei,代碼行數:24,代碼來源:ImageExt.java

示例3: make

import nars.io.Symbols; //導入依賴的package包/類
/**
 * Try to make a new compound from two components. Called by the inference rules.
 * @param subject The first component
 * @param predicate The second component
 * @param memory Reference to the memory
 * @return A compound generated or null
 */
public static Similarity make(Term subject, Term predicate, Memory memory) {
    if (invalidStatement(subject, predicate)) {
        return null;
    }
    if (subject.compareTo(predicate) > 0) {
        return make(predicate, subject, memory);
    }
    String name = makeStatementName(subject, Symbols.Relation.SIMILARITY.toString(), predicate);
    Term t = memory.nameToListedTerm(name);
    if (t != null) {
        return (Similarity) t;
    }
    ArrayList<Term> argument = argumentsToList(subject, predicate);
    return new Similarity(argument);
}
 
開發者ID:opennars,項目名稱:pei,代碼行數:23,代碼來源:Similarity.java

示例4: Stamp

import nars.io.Symbols; //導入依賴的package包/類
/**
 * Generate a new stamp, with a new serial number, for a new Task
 *
 * @param time Creation time of the stamp
 */
public Stamp(final long time, final String tense) {
    currentSerial++;
    baseLength = 1;
    evidentialBase = new long[baseLength];
    evidentialBase[0] = currentSerial;
    creationTime = time;
    if (tense.length() == 0) {
        occurrenceTime = ETERNAL;
    } else if (tense.equals(Symbols.TENSE_PAST)) {
        occurrenceTime = time - 1;
    } else if (tense.equals(Symbols.TENSE_FUTURE)) {
        occurrenceTime = time + 1;
    } else { // if (tense.equals(Symbols.TENSE_PRESENT)) 
        occurrenceTime = time;
    }
    derivationChain = new ArrayList<>();
}
 
開發者ID:opennars,項目名稱:pei,代碼行數:23,代碼來源:Stamp.java

示例5: convertedJudgment

import nars.io.Symbols; //導入依賴的package包/類
/**
 * Convert jusgment into different relation
 * <p>
 * called in MatchingRules
 * @param budget The budget value of the new task
 * @param truth The truth value of the new task
 * @param memory Reference to the memory
 */
private static void convertedJudgment(TruthValue newTruth, BudgetValue newBudget, Memory memory) {
    Statement content = (Statement) memory.currentTask.getContent();
    Statement beliefContent = (Statement) memory.currentBelief.getContent();
    Term subjT = content.getSubject();
    Term predT = content.getPredicate();
    Term subjB = beliefContent.getSubject();
    Term predB = beliefContent.getPredicate();
    Term otherTerm;
    if (Variable.containVarQuery(subjT.getName())) {
        otherTerm = (predT.equals(subjB)) ? predB : subjB;
        content = Statement.make(content, otherTerm, predT, memory);
    }
    if (Variable.containVarQuery(predT.getName())) {
        otherTerm = (subjT.equals(subjB)) ? predB : subjB;
        content = Statement.make(content, subjT, otherTerm, memory);
    }
    memory.singlePremiseTask(content, Symbols.JUDGMENT_MARK, newTruth, newBudget);
}
 
開發者ID:opennars,項目名稱:pei,代碼行數:27,代碼來源:LocalRules.java

示例6: makeImageName

import nars.io.Symbols; //導入依賴的package包/類
/**
 * default method to make the oldName of an image term from given fields
 * @param op the term operator
 * @param arg the list of components
 * @param relationIndex the location of the place holder
 * @return the oldName of the term
 */
protected static String makeImageName(String op, ArrayList<Term> arg, int relationIndex) {
    StringBuffer name = new StringBuffer();
    name.append(Symbols.COMPOUND_TERM_OPENER);
    name.append(op);
    name.append(Symbols.ARGUMENT_SEPARATOR);
    name.append(arg.get(relationIndex).getName());
    for (int i = 0; i < arg.size(); i++) {
        name.append(Symbols.ARGUMENT_SEPARATOR);
        if (i == relationIndex) {
            name.append(Symbols.IMAGE_PLACE_HOLDER);
        } else {
            name.append(arg.get(i).getName());
        }
    }
    name.append(Symbols.COMPOUND_TERM_CLOSER);
    return name.toString();
}
 
開發者ID:opennars,項目名稱:pei,代碼行數:25,代碼來源:CompoundTerm.java

示例7: make

import nars.io.Symbols; //導入依賴的package包/類
/**
 * Try to make a new compound from two components. Called by the inference rules.
 * @param subject The first compoment
 * @param predicate The second compoment
 * @param memory Reference to the memeory
 * @return A compound generated or null
 */
public static Similarity make(Term subject, Term predicate, Memory memory) {
    if (invalidStatement(subject, predicate)) {
        return null;
    }
    if (subject.compareTo(predicate) > 0) {
        return make(predicate, subject, memory);
    }
    String name = makeStatementName(subject, Symbols.SIMILARITY_RELATION, predicate);
    Term t = memory.nameToListedTerm(name);
    if (t != null) {
        return (Similarity) t;
    }
    ArrayList<Term> argument = argumentsToList(subject, predicate);
    return new Similarity(argument);
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:23,代碼來源:Similarity.java

示例8: make

import nars.io.Symbols; //導入依賴的package包/類
/**
 * Try to make a new compound from two components. Called by the inference rules.
 * @param subject The first component
 * @param predicate The second component
 * @param memory Reference to the memory
 * @return A compound generated or null
 */
public static Equivalence make(Term subject, Term predicate, Memory memory) {  // to be extended to check if subject is Conjunction
    if ((subject instanceof Implication) || (subject instanceof Equivalence)) {
        return null;
    }
    if ((predicate instanceof Implication) || (predicate instanceof Equivalence)) {
        return null;
    }
    if (invalidStatement(subject, predicate)) {
        return null;
    }
    if (subject.compareTo(predicate) > 0) {
        Term interm = subject;
        subject = predicate;
        predicate = interm;
    }
    String name = makeStatementName(subject, Symbols.EQUIVALENCE_RELATION, predicate);
    Term t = memory.nameToListedTerm(name);
    if (t != null) {
        return (Equivalence) t;
    }
    ArrayList<Term> argument = argumentsToList(subject, predicate);
    return new Equivalence(argument);
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:31,代碼來源:Equivalence.java

示例9: isOperator

import nars.io.Symbols; //導入依賴的package包/類
/**
 * Check CompoundTerm operator symbol
 * @return if the given String is an operator symbol
 * @param s The String to be checked
 */
public static boolean isOperator(String s) {
    if (s.length() == 1) {
        return (s.equals(Symbols.INTERSECTION_EXT_OPERATOR) ||
                s.equals(Symbols.INTERSECTION_INT_OPERATOR) ||
                s.equals(Symbols.DIFFERENCE_EXT_OPERATOR) ||
                s.equals(Symbols.DIFFERENCE_INT_OPERATOR) ||
                s.equals(Symbols.PRODUCT_OPERATOR) ||
                s.equals(Symbols.IMAGE_EXT_OPERATOR) ||
                s.equals(Symbols.IMAGE_INT_OPERATOR));
    }
    if (s.length() == 2) {
        return (s.equals(Symbols.NEGATION_OPERATOR) ||
                s.equals(Symbols.DISJUNCTION_OPERATOR) ||
                s.equals(Symbols.CONJUNCTION_OPERATOR));
    }
    return false;
}
 
開發者ID:opennars,項目名稱:pei,代碼行數:23,代碼來源:CompoundTerm.java

示例10: conditionalDedIndWithVar

import nars.io.Symbols; //導入依賴的package包/類
/**
 * Conditional deduction or induction, with variable unification
 *
 * @param conditional The premise that is an Implication with a Conjunction
 * as condition
 * @param index The location of the shared term in the condition
 * @param statement The second premise that is a statement
 * @param side The location of the shared term in the statement
 * @param memory Reference to the memory
 */
private static void conditionalDedIndWithVar(Implication conditional, short index, Statement statement, short side, Memory memory) {
    CompoundTerm condition = (CompoundTerm) conditional.getSubject();
    Term component = condition.componentAt(index);
    Term component2 = null;
    if (statement instanceof Inheritance) {
        component2 = statement;
        side = -1;
    } else if (statement instanceof Implication) {
        component2 = statement.componentAt(side);
    }

    if (component2 != null) {
        boolean unifiable = Variable.unify(Symbols.VAR_INDEPENDENT, component, component2, conditional, statement);
        if (!unifiable) {
            unifiable = Variable.unify(Symbols.VAR_DEPENDENT, component, component2, conditional, statement);
        }
        if (unifiable) {
            SyllogisticRules.conditionalDedInd(conditional, index, statement, side, memory);
        }
    }
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:32,代碼來源:RuleTables.java

示例11: contraposition

import nars.io.Symbols; //導入依賴的package包/類
/**
 * {<A ==> B>, [email protected](--, A)} |- <(--, B) ==> (--, A)>
 * @param statement The premise
 * @param memory Reference to the memory
 */
static void contraposition(Statement statement, Sentence sentence, Memory memory) {
    Term subj = statement.getSubject();
    Term pred = statement.getPredicate();

    Term content = Statement.make(statement, Negation.make(pred, memory), Negation.make(subj, memory), memory);
    TruthValue truth = sentence.getTruth();
    BudgetValue budget;
    if (sentence.isQuestion()) {
        if (content instanceof Implication) {
            budget = BudgetFunctions.compoundBackwardWeak(content, memory);
        } else {
            budget = BudgetFunctions.compoundBackward(content, memory);
        }
    memory.singlePremiseTask(content, Symbols.QUESTION_MARK, truth, budget);            
    } else {
        if (content instanceof Implication) {
            truth = TruthFunctions.contraposition(truth);
        }
        budget = BudgetFunctions.compoundForward(truth, content, memory);
        memory.singlePremiseTask(content, Symbols.JUDGMENT_MARK, truth, budget);
    }
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:28,代碼來源:StructuralRules.java

示例12: detachmentWithVar

import nars.io.Symbols; //導入依賴的package包/類
/**
 * The detachment rule, with variable unification
 *
 * @param originalMainSentence The premise that is an Implication or
 * Equivalence
 * @param subSentence The premise that is the subject or predicate of the
 * first one
 * @param index The location of the second premise in the first
 * @param memory Reference to the memory
 */
private static void detachmentWithVar(Sentence originalMainSentence, Sentence subSentence, int index, Memory memory) {
    Sentence mainSentence = (Sentence) originalMainSentence.clone();   // for substitution
    Statement statement = (Statement) mainSentence.getContent();
    Term component = statement.componentAt(index);
    Term content = subSentence.getContent();
    if (((component instanceof Inheritance) || (component instanceof Negation)) && (memory.currentBelief != null)) {
        if (component.isConstant()) {
            SyllogisticRules.detachment(mainSentence, subSentence, index, memory);
        } else if (Variable.unify(Symbols.VAR_INDEPENDENT, component, content, statement, content)) {
            SyllogisticRules.detachment(mainSentence, subSentence, index, memory);
        } else if ((statement instanceof Implication) && (statement.getPredicate() instanceof Statement) && (memory.currentTask.getSentence().isJudgment())) {
            Statement s2 = (Statement) statement.getPredicate();
            if (s2.getSubject().equals(((Statement) content).getSubject())) {
                CompositionalRules.introVarInner((Statement) content, s2, statement, memory);
            }
        }
    }
}
 
開發者ID:opennars,項目名稱:pei,代碼行數:29,代碼來源:RuleTables.java

示例13: textInputLine

import nars.io.Symbols; //導入依賴的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);
            }
        }
    }
}
 
開發者ID:opennars,項目名稱:pei,代碼行數:28,代碼來源:ReasonerBatch.java

示例14: toString

import nars.io.Symbols; //導入依賴的package包/類
/**
 * Get a String form of the Stamp for display
 * Format: {creationTime [: eventTime] : evidentialBase}
 * @return The Stamp as a String
 */
@Override
public String toString() {
    StringBuffer buffer = new StringBuffer(" " + Symbols.STAMP_OPENER + creationTime);
    buffer.append(" " + Symbols.STAMP_STARTER + " ");
    for (int i = 0; i < baseLength; i++) {
        buffer.append(Long.toString(evidentialBase[i]));
        if (i < (baseLength - 1)) {
            buffer.append(Symbols.STAMP_SEPARATOR);
        } else {
            buffer.append(Symbols.STAMP_CLOSER + " ");
        }
    }
    return buffer.toString();
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:20,代碼來源:Stamp.java

示例15: match

import nars.io.Symbols; //導入依賴的package包/類
/**
 * The task and belief have the same content
 * <p>
 * called in RuleTables.reason
 * @param task The task
 * @param belief The belief
 * @param memory Reference to the memory
 */
public static void match(Task task, Sentence belief, Memory memory) {
    Sentence sentence = (Sentence) task.getSentence().clone();
    if (sentence.isJudgment()) {
        if (revisible(sentence, belief)) {
            revision(sentence, belief, true, memory);
        }
    } else if (Variable.unify(Symbols.VAR_QUERY, sentence.getContent(), (Term) belief.getContent().clone())) {
        trySolution(sentence, belief, task, memory);
    }
}
 
開發者ID:automenta,項目名稱:opennars,代碼行數:19,代碼來源:LocalRules.java


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