Esempio n. 1
0
        /**
         * /param t The target Task
         * /param template The TermLink template
         * /param budget The budget
         */
        public ClassicalTaskLink(ClassicalTask t, ClassicalTermLink template, ClassicalBudgetValue budget, uint recordLength) : base(budget)
        {
            this.type =
                template == null ?
                ClassicalTermLink.EnumType.SELF :
                template.type;
            this.index =
                template == null ?
                null :
                template.index;

            this.targetTask = t;

            this.recordLength = recordLength;
        }
Esempio n. 2
0
        // see https://github.com/opennars/opennars/blob/4515f1d8e191a1f097859decc65153287d5979c5/nars_core/nars/entity/Concept.java#L923

        /**
         * Recursively build TermLinks between a compound and its components
         * <p>
         * called only from Memory.continuedProcess
         *
         * /param taskBudget The BudgetValue of the task
         */
        public void buildTermLinks(ClassicalBudgetValue taskBudget)
        {
            if (termLinkTemplates.Count == 0)
            {
                return;
            }

            ClassicalBudgetValue subBudget = taskBudget; // HACK // uncommented because not yet implemented, TODO     distributeAmongLinks(taskBudget, termLinkTemplates.size());

            if (!subBudget.isAboveThreshold)
            {
                return;
            }

            foreach (ClassicalTermLink template in termLinkTemplates)
            {
                if (template.type == ClassicalTermLink.EnumType.TRANSFORM)
                {
                    continue;
                }

                TermOrCompoundTermOrVariableReferer target = template.target;

                ClassicalConcept concept = memory.conceptualize(taskBudget, target);
                if (concept == null)
                {
                    continue;
                }

                // this termLink to that
                insertTermLink(ClassicalTermLink.makeFromTemplate(target, template, subBudget));

                // that termLink to this
                concept.insertTermLink(ClassicalTermLink.makeFromTemplate(term, template, subBudget));

                if (TermUtilities.isTermCompoundTerm(target) && template.type != ClassicalTermLink.EnumType.TEMPORAL)
                {
                    concept.buildTermLinks(subBudget);
                }
            }
        }
Esempio n. 3
0
 /**
  * Constructor to make actual TermLink from a template
  * <p>
  * called in Concept.buildTermLinks only
  * @param t Target Term
  * @param template TermLink template previously prepared
  * @param v Budget value of the link
  */
 private ClassicalTermLink(TermOrCompoundTermOrVariableReferer target, ClassicalTermLink template, ClassicalBudgetValue budget) : base(budget)
 {
     this.target = target;
     type        = (template.target == target)
             ? (template.type - 1) //// point to component
             : template.type;
     index = template.index;
     // OpenNARS  hash = init();
 }
Esempio n. 4
0
 public static ClassicalTermLink makeFromTemplate(TermOrCompoundTermOrVariableReferer term, ClassicalTermLink template, ClassicalBudgetValue budget)
 {
     return(new ClassicalTermLink(term, template, budget));
 }
Esempio n. 5
0
 public Item(ClassicalBudgetValue budget)
 {
     this.budget = budget;
 }
Esempio n. 6
0
        public ClassicalConcept(CompoundAndTermContext compoundAndTermContext, TermOrCompoundTermOrVariableReferer term, BagBuilder bagBuilder, ClassicalBudgetValue budget, Memory memory) : base(budget)
        {
            this.memory = memory;
            this.term   = term;

            tasks = bagBuilder.createForConcept_tasksBag();

            taskLinks = bagBuilder.createForConcept_taskLinksBag();
            termLinks = bagBuilder.createForConcept_termLinksBag();

            { // calculate term links
                bool isCompoundTerm = !term.isAtomic && !term.isVariable;
                if (isCompoundTerm)
                {
                    // TODO< decide if it is COMPOUND_STATEMENT or COMPOUND >
                    // https://github.com/opennars/opennars/blob/4515f1d8e191a1f097859decc65153287d5979c5/nars_core/nars/language/Terms.java#L470;
                    ClassicalTermLink.EnumType type = ClassicalTermLink.EnumType.COMPOUND;

                    this.termLinkTemplates = TermHelper.prepareComponentLinks(compoundAndTermContext, term, type);
                }
            }
        }
Esempio n. 7
0
 /**
  * Merge one BudgetValue into another
  * @param that The other Budget
  */
 public void merge(ClassicalBudgetValue that)
 {
     BudgetFunctions.merge(this, that);
 }