private ScoreContext InitScoreContext(string userId, ScoreLUInfo currentLUInfo) { ScoreContext scContext = new ScoreContext(userId); scContext.Intent = currentLUInfo.Intent.intent; scContext.currentIndex = 0; return(scContext); }
//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 == "DoMath") { var testLUInfo = new TestLUInfo(); testLUInfo.Course = "数学"; currentLUInfo = testLUInfo; } else if (ruleBasedIntent == "DoEng") { var testLUInfo = new TestLUInfo(); testLUInfo.Course = "英语"; currentLUInfo = testLUInfo; } else if (ruleBasedIntent == "DoDISC") { currentLUInfo = new ExamLUInfo(); } else if (ruleBasedIntent == "Score") { currentLUInfo = new ScoreLUInfo(); } 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); }