Ejemplo n.º 1
0
        public override async Task <ParseResult> ParseAsync(ChatState chatState, Chat_ParseField chatParseField, ChatMessage message)
        {
            var preFlowName  = chatParseField.GetProperty("preFlowName");
            var preStepId    = chatParseField.GetProperty("preStepId");
            var postFlowName = chatParseField.GetProperty("postFlowName");
            var postStepId   = chatParseField.GetProperty("postStepId");

            if (String.IsNullOrEmpty(preFlowName) ||
                String.IsNullOrEmpty(preStepId) ||
                String.IsNullOrEmpty(postFlowName) ||
                String.IsNullOrEmpty(postStepId))
            {
                throw new ApplicationException("Parse: Missing rule data for IntentGateway Parser.");
            }

            message.Classifications = await ClassifyText(message.CorrectedUserInput, preFlowName, preStepId, postFlowName, postStepId, chatState.SessionData.IsSmsChannel);

            chatState.UpdateLastClassification(message.Classifications);

            if (!message.Classifications.IsSuccessful)
            {
                return(ParseResult.Failed);
            }

            // We don't want common chat intent's here.
            var intent = chatState.LastClassification.GetBestResult().Intent;

            if (intent != null && intent.StartsWith("commonchat-"))
            {
                return(ParseResult.Failed);
            }

            return(ParseResult.CreateSuccess(message.Classifications.GetBestResult().Result));
        }
Ejemplo n.º 2
0
        public override async Task <ParseResult> ParseAsync(ChatState chatState, Chat_ParseField chatParseField, ChatMessage message)
        {
            // Strip PII data
            string text        = filterService.FilterUserData(chatState, message.CorrectedUserInput, false);
            string classifiers = chatParseField?.GetProperty("Classifiers") ?? defaultClassifier;

            message.Classifications = await classificationService.ClassifyAsync(classifiers, threshold, text, false, chatState.SessionData.IsSmsChannel);

            chatState.UpdateLastClassification(message.Classifications);

            if (message.Classifications.IsSuccessful)
            {
                // We don't want common chat intent's here.
                if (message.Classifications.GetBestResult().Intent.StartsWith("commonchat-"))
                {
                    return(ParseResult.Failed);
                }

                return(ParseResult.CreateSuccess(message.Classifications.GetBestResult().Intent));
            }

            return(ParseResult.Failed);
        }