public MainWindow() { InitializeComponent(); var loader = new AIMLLoader(); const string path = @"Human.aiml"; loader.LoadAIML(path); }
public void Setup() { _chatBot = new ChatBot(); ChatBot.Size = 0; _loader = new AIMLLoader(); var path = $@"{Environment.CurrentDirectory}\AIML\Salutations.aiml"; _loader.LoadAIML(path); }
public void Initialize() { _chatBot = new ChatBot(); _loader = new AIMLLoader(); const string path = @"AIML\ChatBotTests.aiml"; { _loader.LoadAIML(path); } }
public void Initialize() { _chatBot = new ChatBot(); _loader = new AIMLLoader(_chatBot); var assembly = Assembly.GetExecutingAssembly(); using (var stream = assembly.GetManifestResourceStream("AIMLbot.UnitTest.AIML.Salutations.aiml")) { _loader.LoadAIML(stream); } }
public override string ProcessChange() { if (Template.Name.ToLower() != "learn") return string.Empty; // currently only AIML files in the local filesystem can be referenced // ToDo: Network HTTP and web service based learning if (Template.InnerText.Length > 0) { var path = Template.InnerText; var fi = new FileInfo(path); try { var loader = new AIMLLoader(); loader.LoadAIML(fi); } catch (Exception ex) { Log.Error("Unable to learn some new AIML from the following URI: " + path, ex); } } return string.Empty; }
/// <summary> /// Given a request containing user input, produces a result from the bot /// </summary> /// <param name="request">the request from the user</param> /// <returns>the result to be output to the user</returns> public Result Chat(Request request) { Result result = new Result(request.user, this, request); if (this.isAcceptingUserInput) { // Normalize the input AIMLLoader loader = new AIMLLoader(this); AIMLbot.Normalize.SplitIntoSentences splitter = new AIMLbot.Normalize.SplitIntoSentences(this); string[] rawSentences = splitter.Transform(request.rawInput); foreach (string sentence in rawSentences) { result.InputSentences.Add(sentence); string path = loader.generatePath(sentence, request.user.getLastBotOutput(), request.user.Topic, true); result.NormalizedPaths.Add(path); } // grab the templates for the various sentences from the graphmaster foreach (string path in result.NormalizedPaths) { Utils.SubQuery query = new SubQuery(path); query.Template = this.Graphmaster.evaluate(path, query, request, MatchState.UserInput, new StringBuilder()); result.SubQueries.Add(query); } // process the templates into appropriate output foreach (SubQuery query in result.SubQueries) { if (query.Template.Length > 0) { try { XmlNode templateNode = AIMLTagHandler.getNode(query.Template); string outputSentence = this.processNode(templateNode, query, request, result, request.user); if (outputSentence.Length > 0) { result.OutputSentences.Add(outputSentence); } } catch (Exception e) { if (this.WillCallHome) { this.phoneHome(e.Message, request); } this.writeToLog("WARNING! A problem was encountered when trying to process the input: " + request.rawInput + " with the template: \"" + query.Template + "\""); } } } } else { result.OutputSentences.Add(this.NotAcceptingUserInputMessage); } // populate the Result object result.Duration = DateTime.Now - request.StartedOn; request.user.addResult(result); return result; }
/// <summary> /// Allows the bot to load a new XML version of some AIML /// </summary> /// <param name="newAIML">The XML document containing the AIML</param> /// <param name="filename">The originator of the XML document</param> public void loadAIMLFromXML(XmlDocument newAIML, string filename) { AIMLLoader loader = new AIMLLoader(this); loader.loadAIMLFromXML(newAIML, filename); }
/// <summary> /// Loads AIML from .aiml files into the graphmaster "brain" of the bot /// </summary> public void loadAIMLFromFiles() { AIMLLoader loader = new AIMLLoader(this); loader.loadAIML(); }
public void TestLoadAIMLFileWithValidXMLButMissingTemplate() { var path = @"AIML\MissingPattern.aiml"; _loader = new AIMLLoader(); _loader.LoadAIML(path); }
public void TestLoadAIMLFileWithBadXML() { var path = @"AIML\BadlyFormed.aiml"; _loader = new AIMLLoader(); _loader.LoadAIML(path); }
/// <summary> /// Allows the ChatBot to load a new XML version of some AIML /// </summary> /// <param name="newAIML">The XML document containing the AIML</param> public void LoadAIML(XDocument newAIML) { var loader = new AIMLLoader(); loader.LoadAIML(newAIML); }
public void LoadAIML(string path) { var loader = new AIMLLoader(); loader.LoadAIML(path); }
/// <summary> /// Loads AIML from .aiml files into the graphmaster "brain" of the ChatBot /// </summary> public void LoadAIML() { var loader = new AIMLLoader(); loader.LoadAIML(); }