当前位置: 首页>>代码示例>>Java>>正文


Java Term.equals方法代码示例

本文整理汇总了Java中nars.language.Term.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Term.equals方法的具体用法?Java Term.equals怎么用?Java Term.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nars.language.Term的用法示例。


在下文中一共展示了Term.equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: novel

import nars.language.Term; //导入方法依赖的package包/类
/**
 * To check whether a TaskLink should use a TermLink, return false if they 
 * interacted recently
 * <p>
 * called in TermLinkBag only
 * @param termLink The TermLink to be checked
 * @param currentTime The current time
 * @return Whether they are novel to each other
 */
public boolean novel(TermLink termLink, long currentTime) {
    Term bTerm = termLink.getTarget();
    if (bTerm.equals(targetTask.getSentence().getContent())) {
        return false;
    }
    String linkKey = termLink.getKey();
    int next = 0;
    int i;
    for (i = 0; i < counter; i++) {
        next = i % Parameters.TERM_LINK_RECORD_LENGTH;
        if (linkKey.equals(recordedLinks[next])) {
            if (currentTime < recordingTime[next] + Parameters.TERM_LINK_RECORD_LENGTH) {
                return false;
            } else {
                recordingTime[next] = currentTime;
                return true;
            }
        }
    }
    next = i % Parameters.TERM_LINK_RECORD_LENGTH;
    recordedLinks[next] = linkKey;       // add knowledge reference to recordedLinks
    recordingTime[next] = currentTime;
    if (counter < Parameters.TERM_LINK_RECORD_LENGTH) { // keep a constant length
        counter++;
    }
    return true;
}
 
开发者ID:automenta,项目名称:opennars,代码行数:37,代码来源:TaskLink.java

示例2: novel

import nars.language.Term; //导入方法依赖的package包/类
/**
 * To check whether a TaskLink should use a TermLink, return false if they
 * interacted recently
 * <p>
 * called in TermLinkBag only
 *
 * @param termLink The TermLink to be checked
 * @param currentTime The current time
 * @return Whether they are novel to each other
 */
public boolean novel(final TermLink termLink, final long currentTime) {
    final Term bTerm = termLink.getTarget();
    if (bTerm.equals(targetTask.getSentence().getContent())) {
        return false;
    }
    String linkKey = termLink.getKey();
    int next, i;
    for (i = 0; i < counter; i++) {
        next = i % Parameters.TERM_LINK_RECORD_LENGTH;
        if (linkKey.equals(recordedLinks[next])) {
            if (currentTime < recordingTime[next] + Parameters.TERM_LINK_RECORD_LENGTH) {
                return false;
            } else {
                recordingTime[next] = currentTime;
                return true;
            }
        }
    }
    next = i % Parameters.TERM_LINK_RECORD_LENGTH;
    recordedLinks[next] = linkKey;       // add knowledge reference to recordedLinks
    recordingTime[next] = currentTime;
    if (counter < Parameters.TERM_LINK_RECORD_LENGTH) { // keep a constant length
        counter++;
    }
    return true;
}
 
开发者ID:automenta,项目名称:opennars,代码行数:37,代码来源:TaskLink.java

示例3: testConjunctionTreeSet

import nars.language.Term; //导入方法依赖的package包/类
@Test
public void testConjunctionTreeSet() {
    NAR n = new NAR();
    
    try {           
        
        String term1String ="<#1 --> (&,boy,(/,taller_than,{Tom},_))>";
        Term term1 = TextInput.parseTerm(term1String, n.memory);

        // <#1 --> (|,boy,(/,taller_than,{Tom},_))>
        Term term2 = TextInput.parseTerm("<#1 --> (|,boy,(/,taller_than,{Tom},_))>", n.memory);
   
        assertTrue(term1.toString().equals(term1String));
        assertTrue(term1.getComplexity() > 1);
        assertTrue(term1.getComplexity() == term2.getComplexity());
                    
        assertTrue(term1.getClass().equals(Inheritance.class));
        assertTrue(term1.getClass().equals(Inheritance.class));
        
        /*
        System.out.println("t1: " + term1 + ", complexity=" + term1.getComplexity());
        System.out.println("t2: " + term2 + ", complexity=" + term2.getComplexity());
        */
        
        assertTrue(term1.equals(term1.clone()));
        assertTrue(term1.compareTo((Term)term1.clone())==0);            
        assertTrue(term2.equals(term2.clone()));
        assertTrue(term2.compareTo((Term)term2.clone())==0);
        
        boolean t1e2 = term1.equals(term2);
        int t1c2 = term1.compareTo(term2);
        int t2c1 = term2.compareTo(term1);

        assertTrue(!t1e2);
        assertTrue("term1 and term2 inequal, so t1.compareTo(t2) should not = 0", t1c2!=0);
        assertTrue("term1 and term2 inequal, so t2.compareTo(t1) should not = 0", t2c1!=0);
        
        /*
        System.out.println("t1 equals t2 " + t1e2);
        System.out.println("t1 compareTo t2 " + t1c2);
        System.out.println("t2 compareTo t1 " + t2c1);
        */
        
        TreeSet<Term> set = new TreeSet<Term>();
        boolean added1 = set.add((Term) term1.clone());
        boolean added2 = set.add((Term) term2.clone());
        assertTrue("term 1 added to set", added1);
        assertTrue("term 2 added to set", added2);
        
        assertTrue(set.size() == 2);
    }
    catch (InvalidInputException e) {
        assertTrue(e.toString(), false);
    }
}
 
开发者ID:automenta,项目名称:opennars,代码行数:56,代码来源:TermTest.java


注:本文中的nars.language.Term.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。