public IEnumerable <TermMatch> Match(IDialogContext context, T state, FormState form, string input) { IEnumerable <TermMatch> matches = null; Debug.Assert(form.Phase() == StepPhase.Responding); var stepState = (FieldStepState)form.StepState; if (stepState.State == FieldStepStates.SentPrompt) { matches = _field.Prompt.Recognizer.Matches(input, _field.GetValue(state)); } else if (stepState.State == FieldStepStates.SentClarify) { var fieldState = (FieldStepState)form.StepState; var iprompt = _field.Prompt; var choiceRecognizer = ClarifyRecognizer(fieldState, iprompt.Recognizer); matches = MatchAnalyzer.Coalesce(MatchAnalyzer.HighestConfidence(choiceRecognizer.Matches(input)), input).ToArray(); if (matches.Count() > 1) { matches = new TermMatch[0]; } } #if DEBUG if (FormDialog.DebugRecognizers) { MatchAnalyzer.PrintMatches(matches, 2); } #endif return(matches); }
public IEnumerable <TermMatch> Match(IDialogContext context, T state, FormState form, IMessageActivity input) { IEnumerable <TermMatch> matches = null; Debug.Assert(form.Phase() == StepPhase.Responding); var stepState = (FieldStepState)form.StepState; if (stepState.State == FieldStepStates.SentPrompt) { matches = _field.Prompt.Recognizer.Matches(input, _field.GetValue(state)); } else if (stepState.State == FieldStepStates.SentClarify) { var fieldState = (FieldStepState)form.StepState; var iprompt = _field.Prompt; var choiceRecognizer = ClarifyRecognizer(fieldState, iprompt.Recognizer); matches = MatchAnalyzer.Coalesce(MatchAnalyzer.HighestConfidence(choiceRecognizer.Matches(input)), MessageActivityHelper.GetSanitizedTextInput(input)).ToArray(); if (matches.Count() > 1) { matches = new TermMatch[0]; } } return(matches); }