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); }
internal StateGraphBuilder Edge(EdgeIdentifier edge, StateGraphBuilder nextState) { var trigger = new Trigger(nextState, null); _directEdges.Add(edge, trigger); return(this); }
internal StateGraphBuilder DefaultForward(StateGraphBuilder nextState, StateProperty2 inputProperty = null) { DefaultTrigger = new Trigger(nextState, (c) => { c.SetValue(inputProperty, c.Input); c.CurrentOutput = c.PreviousOutput; }); return(this); }
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); }
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"); } }
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); }
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); }
internal Trigger(StateGraphBuilder targetNode, TriggerAction action) { TargetNode = targetNode; _action = action; }
internal StateGraphBuilder Edge(string pattern, StateGraphBuilder nextState, params StateProperty2[] properties) { addEdge(pattern, nextState, (c) => setProperties(c, properties)); return(this); }
internal StateGraphBuilder Default(StateGraphBuilder nextState, StateProperty2 inputProperty = null) { DefaultTrigger = new Trigger(nextState, (c) => c.SetValue(inputProperty, c.Input)); return(this); }
private void addEdge(string pattern, StateGraphBuilder nextState, TriggerAction action) { var trigger = new Trigger(nextState, action); Triggers.SetMapping(pattern, trigger); }