Example #1
0
        private void _print(BodyContext context)
        {
            if (!context.RequireParameter("What should be printed?", out var subject))
            {
                return;
            }

            context.SetValue("output", subject.Name);
        }
Example #2
0
        private void _databaseSearch(BodyContext context)
        {
            if (!context.RequireParameter("Which database should I search in?", out var database, context.Databases))
            {
                return;
            }

            var allCriterions = context.GetCriterions(database);

            if (!context.RequireMultiParameter("Which criterions should be used for the database search?", out var selectedCriterions, allCriterions))
            {
                return;
            }

            throw new NotImplementedException("Add the real search as a callback to context");
        }
Example #3
0
        private BodyState assignParameter(BodyState initialState, ConceptRequirement requirement, Concept assignedConcept)
        {
            if (!requirement.Domain.Contains(assignedConcept))
            {
                return(null);
            }

            var parameterScore = _body.ParameterAssignScore(initialState, requirement, assignedConcept);

            if (parameterScore <= 0)
            {
                return(null);
            }

            var assignedState = initialState.AssignParameter(requirement, assignedConcept, parameterScore);
            var context       = new BodyContext(requirement.RequestingConcept, _body, assignedState);

            context.EvaluateActivation(requirement.RequestingConcept.Concept);
            return(context.CurrentState);
        }
Example #4
0
        private IEnumerable <BodyState> setPointer(BodyState inputState, Phrase phrase, Concept concept, double pointingProbability)
        {
            if (pointingProbability <= 0)
            {
                yield break;
            }

            var rankedConcept = new RankedConcept(concept, pointingProbability);
            var state         = inputState.SetPointer(phrase, rankedConcept);
            var context       = new BodyContext(rankedConcept, _body, state);

            context.EvaluateActivation(concept);

            yield return(context.CurrentState);

            var assignmentInitialState = context.CurrentState;

            //try parameter assignments
            foreach (var requirement in assignmentInitialState.PendingRequirements)
            {
                foreach (var mentionedConcept in assignmentInitialState.RecentMentionedConcepts)
                {
                    if (mentionedConcept == requirement.RequestingConcept.Concept)
                    {
                        //don't allow self assignments
                        continue;
                    }

                    var newState = assignParameter(assignmentInitialState, requirement, mentionedConcept);
                    if (newState != null)
                    {
                        yield return(newState);
                    }
                }
            }
        }
Example #5
0
 private void _nativeValue(BodyContext context)
 {
     //native values does not need to process context anyhow
 }