public ChatBotForm() { InitializeComponent(); this.verbot = new Verbot5Engine(); this.state = new State(); this.speaker = new SpeechSynthesizer(); this.recognizer = new SpeechRecognitionEngine(); this.openFileDialog1.Filter = this.stCKBFileFilter; this.Text = this.stFormName; }
public string ExecuteOnNoRuleFired(State s, Reply r) { string ret = ""; if (this.standardNoRuleFiredDefined) { object[] args = { s, r }; ret = this.ExecuteStandardJob(this.STD_EVENT_NAME_NO_RULE_FIRED, args); } return ret; }
public Reply GetReply(FURRE Furre, string input, State state) { DateTime FurcTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time")); state.Vars["_input"] = input; state.Vars["_lastinput"] = state.Lastinput; state.Vars["_lastfired"] = state.Lastfired; state.Vars["_time"] = FurcTime.ToString("h:mm tt"); state.Vars["_time24"] = FurcTime.ToString("HH:mm"); state.Vars["_date"] = FurcTime.ToString("MMM. d, yyyy"); state.Vars["_month"] = FurcTime.ToString("MMMM"); state.Vars["_dayofmonth"] = FurcTime.ToString("d ").Trim(); state.Vars["_year"] = FurcTime.ToString("yyyy"); state.Vars["_dayofweek"] = FurcTime.ToString("dddd"); state.Vars["furrename"] = Furre.Name; state.Vars["furregender"] = Furre.Gender.ToString(); state.Vars["furrespecies"] = Furre.DSSpecies.ToString(); if (input.Length == 0) input = "_blank"; state.Lastinput = input; bool standardNoRuleFiredDefined = false; Reply noRuleFiredReply = new Reply("", "", "", "", 0.0, null); foreach (string stPath in state.CurrentKBs) { if (this.compiledKnowledgeBases.ContainsKey(stPath)) { CompiledKnowledgeBase ckb = (CompiledKnowledgeBase)this.compiledKnowledgeBases[stPath]; string ckbOutput = ckb.CSToolbox.ExecuteOnBeforeRuleFired(state); //update our input var incase the Before Rule Fired changes it input = (string)state.Vars["_input"]; state.Lastinput = input; Reply reply = ckb.GetReply(Furre, input, state.Lastfired, state.Vars, ckbOutput); if (reply != null) { ckbOutput = ckb.CSToolbox.ExecuteOnAfterRuleFired(state, reply); string outputText = ckb.DoTextReplacements( ckbOutput); string agentText = ckb.DoAgentTextReplacements(ckbOutput); reply.Text += outputText; reply.AgentText += agentText; state.Lastfired = reply.RuleId; state.Vars["_lastoutput"] = reply.Text; return reply; } if (ckb.CSToolbox.StandardNoRuleFiredDefined) { standardNoRuleFiredDefined = true; //if this ckb has a no rule fired handler, fire it noRuleFiredReply.KBItem = ckb.KnowledgeBaseItem; string noReplyText = ckb.CSToolbox.ExecuteOnNoRuleFired(state, noRuleFiredReply); noRuleFiredReply.Text += ckb.DoTextReplacements( noReplyText); noRuleFiredReply.AgentText += ckb.DoAgentTextReplacements(noReplyText); } } } if (standardNoRuleFiredDefined) return noRuleFiredReply; return null; //if there's no reply, return null }
public string ExecuteOnBeforeRuleFired(State s) { string ret = ""; if (this.standardBeforeRuleFiredDefined) { object[] args = { s }; ret = this.ExecuteStandardJob(this.STD_EVENT_NAME_BEFORE_RULE_FIRED, args); } return ret; }