Пример #1
0
        private Nar(CompoundAndTermContext compoundAndTermContext, RuntimeParameters runtimeParameters)
        {
            Memory m = createMemory(compoundAndTermContext, runtimeParameters);

            this.memory = m;
            this.param  = runtimeParameters;
        }
Пример #2
0
        // TODO< overhaul so it returns RefererOrInterval >
        public TermOrCompoundTermOrVariableReferer right(CompoundAndTermContext compoundAndTermContext)
        {
            TermTuple dereferencedCompoundTuple = compoundAndTermContext.accessTermTupleByIndex(termTupleIndex);

            Debug.Assert(dereferencedCompoundTuple.refererOrIntervals.Length == 2, "only valid for binary compounds");
            Debug.Assert(dereferencedCompoundTuple.refererOrIntervals[1].isReferer);
            return(dereferencedCompoundTuple.refererOrIntervals[1].referer);
        }
Пример #3
0
        static Memory createMemory(CompoundAndTermContext compoundAndTermContext, RuntimeParameters runtimeParameters)
        {
            IAttentionMechanism <ClassicalTask> attentionMechanism = new BagBasedAttentionMechanism();

            attentionMechanism.setMaxSize(Parameters.NOVEL_TASK_BAG_SIZE);

            return(new Memory(
                       compoundAndTermContext,
                       runtimeParameters,
                       attentionMechanism
                       //commented because OpenNARS version   new ArrayBag<>(Parameters.SEQUENCE_BAG_LEVELS, Parameters.SEQUENCE_BAG_SIZE)
                       ));
        }
Пример #4
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);
        }
Пример #5
0
        public string getDebugStringRecursive(CompoundAndTermContext compoundAndTermContext)
        {
            if (thisTermReferer.isIndependentVariable)
            {
                return(String.Format("${0}", thisTermReferer.getIndependentVariable));
            }
            else if (thisTermReferer.isDependentVariable)
            {
                return(String.Format("#{0}", thisTermReferer.getDependentVariable));
            }
            else if (!thisTermReferer.isSpecial)
            {
                if (thisTermReferer.isAtomic)
                {
                    // TODO< return name if there is a human readable name >

                    return(String.Format("c:{0}", thisTermReferer.getAtomic));

                    //return String.Format("c:{0}:{1}", thisTermReferer.getAtomic, compoundAndTermContext.termNamesByhumanReadableName[thisTermReferer.getAtomic]);
                }
                else
                {
                    string
                        debugStringForLeft  = compoundAndTermContext.getDebugStringByTermReferer(left(compoundAndTermContext)),
                        debugStringForRight = compoundAndTermContext.getDebugStringByTermReferer(right(compoundAndTermContext));

                    // TODO< check if the term is prefix or nonprefix >
                    // TODO< implement for nonbinary >
                    return(String.Format("<{0} {1} {2}>", debugStringForLeft, flagsOfCopula.convToHumanString(), debugStringForRight));
                }
            }
            else
            {
                throw new Exception("Term referer is not a variable or not special, not handled, is an internal error");
            }
        }
Пример #6
0
        public uint getComponentLength(CompoundAndTermContext compoundAndTermContext)
        {
            TermTuple dereferencedCompoundTuple = compoundAndTermContext.accessTermTupleByIndex(termTupleIndex);

            return((uint)dereferencedCompoundTuple.refererOrIntervals.Length);
        }
Пример #7
0
        public RefererOrInterval getComponentByIndex(CompoundAndTermContext compoundAndTermContext, uint index)
        {
            TermTuple dereferencedCompoundTuple = compoundAndTermContext.accessTermTupleByIndex(termTupleIndex);

            return(dereferencedCompoundTuple.refererOrIntervals[index]);
        }
Пример #8
0
        public static Nar make(CompoundAndTermContext compoundAndTermContext, RuntimeParameters runtimeParameters)
        {
            Nar created = new Nar(compoundAndTermContext, runtimeParameters);

            return(created);
        }
Пример #9
0
 public PrototypingInput(CompoundAndTermContext compoundAndTermContext)
 {
     this.compoundAndTermContext = compoundAndTermContext;
 }