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
        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. 3
0
        public static IList <ClassicalTermLink> prepareComponentLinks(CompoundAndTermContext compoundAndTermContext, TermOrCompoundTermOrVariableReferer term, ClassicalTermLink.EnumType type)
        {
            // see https://github.com/opennars/opennars/blob/4515f1d8e191a1f097859decc65153287d5979c5/nars_core/nars/language/Terms.java#L404

            IList <ClassicalTermLink> componentLinks = new List <ClassicalTermLink>();

            // doesn't go down a level because the Concept already does this for us

            Compound compoundOfTerm = compoundAndTermContext.translateTermOfCompoundToCompound(term);

            for (int componentIndex = 0; componentIndex < compoundOfTerm.getComponentLength(compoundAndTermContext); componentIndex++)
            {
                RefererOrInterval refererOfInterval = compoundOfTerm.getComponentByIndex(compoundAndTermContext, (uint)componentIndex);
                Debug.Assert(!refererOfInterval.isInterval);
                TermOrCompoundTermOrVariableReferer refered = refererOfInterval.referer;

                componentLinks.Add(new ClassicalTermLink(refered, type, (uint)componentIndex));
            }

            // TODO< other link types >

            return(componentLinks);
        }