예제 #1
0
        //new DBContextManager();

        public LUInfo Understand(string utterance, bool isSingleContact)
        {
            LUInfo currentLUInfo = null;

            if (string.IsNullOrWhiteSpace(utterance))
            {
                currentLUInfo               = new LUInfo();
                currentLUInfo.Intent        = new Intent();
                currentLUInfo.Intent.intent = "Greeting";
                currentLUInfo.EntityList    = new List <Entity>();
            }
            else
            {
                utterance = ruleStore.Preprocess(utterance);

                string ruleBasedIntent = ruleStore.DetermineIntent(utterance);

                if ((!isSingleContact) && (!string.IsNullOrWhiteSpace(ruleBasedIntent)) &&  ruleBasedIntent == "DoTest")
                {
                    ruleBasedIntent = null;
                }

                if (!string.IsNullOrWhiteSpace(ruleBasedIntent))
                {
                    if (ruleBasedIntent == "DoTest")
                    {
                        currentLUInfo = new TestLUInfo();
                    }
                    else if (ruleBasedIntent == "DoDISC")
                    {
                        currentLUInfo = new ExamLUInfo();
                    }
                    else
                    {
                        currentLUInfo = new LUInfo();
                    }

                    currentLUInfo.Intent.intent = ruleBasedIntent;
                    currentLUInfo.Intent.score  = 1;
                    currentLUInfo.EntityList    = new List <Entity>();
                }

                if (currentLUInfo == null)
                {
                    currentLUInfo = this.luisClient.Query(utterance);
                }

                List <Entity> rulebasedEntities = ruleStore.ExtractSlot(utterance);
                if (rulebasedEntities.Count > 0)
                {
                    currentLUInfo.EntityList.AddRange(rulebasedEntities);
                }
            }

            return(currentLUInfo);
        }
예제 #2
0
        private TaskFlowContext InitTFContext(string userId, TestLUInfo currentLUInfo)
        {
            TaskFlowContext tfContext = new TaskFlowContext(userId);

            tfContext.Intent       = currentLUInfo.Intent.intent;
            tfContext.CourseName   = DatetimeUtils.GetCourseName(currentLUInfo);
            tfContext.currentIndex = 0;

            return(tfContext);
        }