当前位置: 首页>>代码示例>>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;未经允许,请勿转载。