コード例 #1
0
        internal StateGraphBuilder HasMatch(UtteranceMapping <ActionBlock> group, StateGraphBuilder nextState, StateProperty2 inputProperty = null)
        {
            var trigger = new Trigger(nextState, (c) => c.SetValue(inputProperty, c.Input));

            _externalTriggers.Add(group, trigger);
            return(this);
        }
コード例 #2
0
        internal StateGraphBuilder Edge(EdgeIdentifier edge, StateGraphBuilder nextState)
        {
            var trigger = new Trigger(nextState, null);

            _directEdges.Add(edge, trigger);
            return(this);
        }
コード例 #3
0
 internal StateGraphBuilder DefaultForward(StateGraphBuilder nextState, StateProperty2 inputProperty = null)
 {
     DefaultTrigger = new Trigger(nextState, (c) =>
     {
         c.SetValue(inputProperty, c.Input);
         c.CurrentOutput = c.PreviousOutput;
     });
     return(this);
 }
コード例 #4
0
        internal StateGraphBuilder YesNoEdge(StateGraphBuilder nextState, StateProperty2 property)
        {
            addEdge("yes", nextState, (c) => c.SetValue(property, StateProperty2.TrueValue));
            addEdge("of course", nextState, (c) => c.SetValue(property, StateProperty2.TrueValue));
            addEdge("yeah", nextState, (c) => c.SetValue(property, StateProperty2.TrueValue));
            addEdge("y", nextState, (c) => c.SetValue(property, StateProperty2.TrueValue));
            addEdge("no", nextState, (c) => c.SetValue(property, StateProperty2.FalseValue));
            addEdge("not", nextState, (c) => c.SetValue(property, StateProperty2.FalseValue));
            addEdge("none", nextState, (c) => c.SetValue(property, StateProperty2.FalseValue));
            addEdge("n", nextState, (c) => c.SetValue(property, StateProperty2.FalseValue));

            return(this);
        }
コード例 #5
0
 internal IEnumerable <MappingControl <Trigger> > GetScore(StateGraphBuilder state)
 {
     if (_utterance != null)
     {
         return(state.UtteranceEdge(_utterance));
     }
     else if (_edge != null)
     {
         return(state.DirectEdge(_edge));
     }
     {
         throw new NotSupportedException("Current transition is not supported");
     }
 }
コード例 #6
0
        internal StateGraphBuilder IsEdge(StateGraphBuilder stateGraphBuilder, StateProperty2 stateProperty)
        {
            this
            .Edge("*", stateGraphBuilder, stateProperty)
            .Edge("his name is *", stateGraphBuilder, stateProperty)
            .Edge("her name is *", stateGraphBuilder, stateProperty)
            .Edge("he is *", stateGraphBuilder, stateProperty)
            .Edge("she is *", stateGraphBuilder, stateProperty)
            .Edge("it is *", stateGraphBuilder, stateProperty)
            .Edge("correct answer is *", stateGraphBuilder, stateProperty)
            .Edge("* is the correct answer", stateGraphBuilder, stateProperty);

            return(this);
        }
コード例 #7
0
        internal StateGraphBuilder TakeEdgesFrom(StateGraphBuilder state)
        {
            if (state.DefaultTrigger != null)
            {
                DefaultTrigger = state.DefaultTrigger;
            }

            Triggers.FillFrom(state.Triggers);
            foreach (var directEdge in state._directEdges)
            {
                _directEdges[directEdge.Key] = directEdge.Value;
            }

            return(this);
        }
コード例 #8
0
ファイル: Trigger.cs プロジェクト: m9ra/KnowledgeDialog
 internal Trigger(StateGraphBuilder targetNode, TriggerAction action)
 {
     TargetNode = targetNode;
     _action    = action;
 }
コード例 #9
0
 internal StateGraphBuilder Edge(string pattern, StateGraphBuilder nextState, params StateProperty2[] properties)
 {
     addEdge(pattern, nextState, (c) => setProperties(c, properties));
     return(this);
 }
コード例 #10
0
 internal StateGraphBuilder Default(StateGraphBuilder nextState, StateProperty2 inputProperty = null)
 {
     DefaultTrigger = new Trigger(nextState, (c) => c.SetValue(inputProperty, c.Input));
     return(this);
 }
コード例 #11
0
        private void addEdge(string pattern, StateGraphBuilder nextState, TriggerAction action)
        {
            var trigger = new Trigger(nextState, action);

            Triggers.SetMapping(pattern, trigger);
        }