def _determine_culture(
        self,
        activity: Activity,
        opt: FindChoicesOptions = FindChoicesOptions()) -> str:
        culture = (PromptCultureModels.map_to_nearest_language(activity.locale)
                   or opt.locale or self.default_locale
                   or PromptCultureModels.English.locale)
        if not culture or not self._default_choice_options.get(culture):
            culture = PromptCultureModels.English.locale

        return culture
    async def on_recognize(self, turn_context: TurnContext,
                           state: Dict[str, object],
                           options: PromptOptions) -> PromptRecognizerResult:
        if not turn_context:
            raise TypeError(
                'ChoicePrompt.on_recognize(): turn_context cannot be None.')

        choices: List[Choice] = options.choices if (
            options and options.choices) else []
        result: PromptRecognizerResult = PromptRecognizerResult()

        if turn_context.activity.type == ActivityTypes.message:
            activity: Activity = turn_context.activity
            utterance: str = activity.text
            opt: FindChoicesOptions = self.recognizer_options if self.recognizer_options else FindChoicesOptions(
            )
            opt.locale = activity.locale if activity.locale else (
                self.default_locale or Culture.English)
            results = ChoiceRecognizers.recognize_choices(
                utterance, choices, opt)

            if results is not None and len(results) > 0:
                result.succeeded = True
                result.value = results[0].resolution

        return result
    async def on_recognize(
        self,
        turn_context: TurnContext,
        state: Dict[str, object],
        options: PromptOptions,
    ) -> PromptRecognizerResult:
        if not turn_context:
            raise TypeError(
                "ChoicePrompt.on_recognize(): turn_context cannot be None.")

        choices: List[Choice] = options.choices if (
            options and options.choices) else []
        result: PromptRecognizerResult = PromptRecognizerResult()

        if turn_context.activity.type == ActivityTypes.message:
            activity: Activity = turn_context.activity
            utterance: str = activity.text
            if not utterance:
                return result
            opt: FindChoicesOptions = self.recognizer_options if self.recognizer_options else FindChoicesOptions(
            )
            opt.locale = self._determine_culture(turn_context.activity, opt)
            results = ChoiceRecognizers.recognize_choices(
                utterance, choices, opt)

            if results is not None and results:
                result.succeeded = True
                result.value = results[0].resolution

        return result