コード例 #1
0
        /// <summary>
        /// Processes the confident QnA Maker answer and get results
        /// </summary>
        /// <param name="context">The database context</param>
        /// <param name="answers">The answers</param>
        /// <param name="entities">The entities</param>
        /// <returns></returns>
        public String ProcessConfidentAnswerAndGetResult(DbContext context, String question, QnAMakerResult answer,
                                                         IEnumerable <EntityRecommendation> entities)
        {
            var parsedAnswers = ParseAnswers(answer);
            var result        = SelectAnswer(parsedAnswers);

            var parameters = LuisEntitiesHelper.ParseEntities(question, entities);

            if (parameters != null)
            {
                result = SubstituteParameters(result, parameters);
            }

            return(SubstitutePlaceholders(context, result, parameters));
        }
コード例 #2
0
        /// <summary>
        /// Replaces the question parameters with their values
        /// </summary>
        /// <param name="question">The question</param>
        /// <param name="entities">The LUIS entities</param>
        /// <returns></returns>
        public IEnumerable <CustomQnAMakerResult> SubstituteQuestionParameters(String sourceQuestion, IEnumerable <CustomQnAMakerResult> answers,
                                                                               IEnumerable <EntityRecommendation> entities)
        {
            if (entities == null || !entities.Any())
            {
                return(answers);
            }

            var parameters = LuisEntitiesHelper.ParseEntities(sourceQuestion, entities);

            foreach (var answer in answers)
            {
                answer.Questions[0] = SubstituteParameters(answer.Questions[0], parameters);
            }

            return(answers);
        }
コード例 #3
0
        /// <summary>
        /// Processes unconfident QnA Maker answer and get results
        /// </summary>
        /// <param name="context">The database context</param>
        /// <param name="answers">The answers</param>
        /// <param name="entities">The entities</param>
        /// <returns></returns>
        public IEnumerable <QnAMakerResult> ProcessUnconfidentAnswer(DbContext context, String question, IEnumerable <QnAMakerResult> answers,
                                                                     IEnumerable <EntityRecommendation> entities)
        {
            if (!answers.Any())
            {
                return(answers);
            }

            var parameters = LuisEntitiesHelper.ParseEntities(question, entities);

            foreach (var answer in answers)
            {
                var parsed = ParseAnswers(answer);
                var result = SelectAnswer(parsed);

                if (parameters != null)
                {
                    result = SubstituteParameters(result, parameters);
                }
                answer.Answer = SubstitutePlaceholders(context, result, parameters);
            }

            return(answers);
        }