Example #1
0
 private IEnumerable <BodyState> inputCombinations(BodyState state, string word)
 {
     if (state.LastInputPhrase != null && state.GetConcept(state.LastInputPhrase) == null)
     {
         yield return(state.ExpandLastPhrase(word)); //expand previous phrase
     }
     yield return(state.AddNewPhrase(word));         //consider last phrase as closed and add new one
 }
Example #2
0
        internal bool RequireMultiParameter(string request, out IEnumerable <Concept> parameter, IEnumerable <Concept> domain = null)
        {
            var realDomain  = getRealDomain(domain);
            var requirement = new ConceptRequirement(request, EvaluatedConcept, realDomain);

            parameter = _currentState.GetMultiParameter(requirement);
            if (parameter == null)
            {
                _currentState = _currentState.AddMultiRequirement(requirement);
            }

            return(parameter != null);
        }
Example #3
0
        private IEnumerable <BodyState> pointCombinations(BodyState state)
        {
            yield return(state); //nothing is pointing from last reference

            foreach (var concept in _body.Concepts)
            {
                var lastInputPhrase    = state.LastInputPhrase;
                var probability        = _body.PointingScore(state, lastInputPhrase, concept);
                var pointingHypotheses = setPointer(state, lastInputPhrase, concept, probability).ToArray();
                foreach (var hypothesis in pointingHypotheses)
                {
                    yield return(hypothesis);
                }
            }
        }
Example #4
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 #5
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 #6
0
 internal double ParameterAssignScore(BodyState currentState, ConceptRequirement parameter, Concept concept)
 {
     return(_model.ParameterAssignScore(currentState, parameter, concept));
 }
Example #7
0
 internal double ReadoutScore(BodyState state)
 {
     return(_model.ReadoutScore(state));
 }
Example #8
0
 internal void SetState(BodyState state)
 {
     _beam.SetState(state);
 }
Example #9
0
 internal double PointingScore(BodyState currentState, Phrase phrase, Concept concept)
 {
     return(_model.PointingScore(currentState, phrase, concept));
 }
Example #10
0
 internal void SetValue(string variable, string value)
 {
     _currentState = _currentState.SetValue(variable, value);
 }
Example #11
0
 public BodyContext(RankedConcept evaluatedConcept, Body body, BodyState inputState)
 {
     _body            = body;
     _currentState    = inputState;
     EvaluatedConcept = evaluatedConcept;
 }
Example #12
0
 internal void SetState(BodyState state)
 {
     _currentStates.Clear();
     _currentStates.Add(state);
 }