private void fromAIMLToolStripMenuItem_Click(object sender, EventArgs e) { try { folderBrowserDialogAIML.RootFolder = Environment.SpecialFolder.MyComputer; folderBrowserDialogAIML.SelectedPath = this.myBot.PathToAIML; DialogResult dr = folderBrowserDialogAIML.ShowDialog(this); if (dr == DialogResult.OK) { AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.myBot); this.myBot.isAcceptingUserInput = false; if (folderBrowserDialogAIML.SelectedPath.Length > 0) { loader.loadAIML(folderBrowserDialogAIML.SelectedPath); } else { loader.loadAIML(this.myBot.PathToAIML); } this.myBot.isAcceptingUserInput = true; } } catch (Exception ex) { this.richTextBoxOutput.Text += ex.Message + Environment.NewLine; } }
//methods public bool initialize_iBOT() { //initialize bot bot = new Bot(); bot.loadSettings(); //TODO: change settings.xml in config //user settings user = new User("DefaultUser", this.bot); //Log writer event setting bot.WrittenToLog += new Bot.LogMessageDelegate(bot_Log); //Initialize the bot's Mind try { AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.bot); this.bot.isAcceptingUserInput = false; loader.loadAIML(AIMLSourcePath); this.bot.isAcceptingUserInput = true; } catch (Exception ex) { ExceptionMsgs += DateTime.Now.ToString() + ">> " + ex.Message + Environment.NewLine; return false; } //the bot is ready to serve! initialized = true; return true; }
public void testLoadAIMLWithEmptyPath() { this.mockBot = new Bot(); this.mockBot.loadSettings(); this.mockBot.GlobalSettings.addSetting("aimldirectory", "aimlEmpty"); this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot); this.mockLoader.loadAIML(); }
public void testLoadAIMLFileWithBadXML() { this.mockBot = new Bot(); this.mockBot.loadSettings(); this.mockBot.GlobalSettings.addSetting("aimldirectory", "badaiml"); this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot); this.mockLoader.loadAIMLFile(Path.Combine(this.mockBot.PathToAIML, "badlyFormed.aiml")); }
public void testLoadAIMLWithValidAIMLfiles() { this.mockBot = new Bot(); this.mockBot.loadSettings(); this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot); this.mockLoader.loadAIML(); Assert.AreEqual(AIMLTagHandlers.sizeTagTests.Size, this.mockBot.Size); }
public void testLoadAIMLWithEmptyPath() { this.mockBot = new Bot(); this.mockBot.loadSettings(); this.mockBot.GlobalSettings.addSetting("aimldirectory", "aimlEmpty"); this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot); this.mockLoader.loadAIML(); }
public void testLoadAIMLFileWithBadXML() { this.mockBot = new Bot(); this.mockBot.loadSettings(); this.mockBot.GlobalSettings.addSetting("aimldirectory", "badaiml"); this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot); this.mockLoader.loadAIMLFile(Path.Combine(this.mockBot.PathToAIML,"badlyFormed.aiml")); }
public void testLoadAIMLFileWithValidXMLButMissingPattern() { this.mockBot = new Bot(); this.mockBot.loadSettings(); this.mockBot.GlobalSettings.addSetting("aimldirectory", "badaiml"); this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot); this.mockLoader.loadAIMLFile(Path.Combine(this.mockBot.PathToAIML, "missingPattern.aiml")); }
public void testLoadAIMLWithValidAIMLfiles() { this.mockBot = new Bot(); this.mockBot.loadSettings(); this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot); this.mockLoader.loadAIML(); Assert.AreEqual(AIMLTagHandlers.sizeTagTests.Size, this.mockBot.Size); }
public void testWithValidData() { XmlNode testNode = StaticHelpers.getNode("<size/>"); this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.size(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, this.mockResult, testNode); Assert.AreEqual("0", this.mockBotTagHandler.Transform()); AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.mockBot); loader.loadAIML(); Assert.AreEqual(Convert.ToString(sizeTagTests.Size), this.mockBotTagHandler.Transform()); }
public void testWithValidData() { XmlNode testNode = StaticHelpers.getNode("<size/>"); this.mockBotTagHandler = new AIMLbot.AIMLTagHandlers.size(this.mockBot, this.mockUser, this.mockQuery, this.mockRequest, this.mockResult, testNode); Assert.AreEqual("0", this.mockBotTagHandler.Transform()); AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.mockBot); loader.loadAIML(); Assert.AreEqual(Convert.ToString(sizeTagTests.Size), this.mockBotTagHandler.Transform()); }
public MainWindow() { bot = new Bot(); user = new User("DefaultUser", bot); bot.loadSettings(); AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(bot); bot.isAcceptingUserInput = false; loader.loadAIML(bot.PathToAIML); bot.isAcceptingUserInput = true; InitializeComponent(); }
public string Ask(string name, string question) { var sharpBot = new Bot(); sharpBot.loadSettings(SettingsPath); var loader = new AIMLbot.Utils.AIMLLoader(sharpBot); loader.loadAIML(aimlPath); sharpBot.isAcceptingUserInput = false; sharpBot.isAcceptingUserInput = true; var patient = new User(name, sharpBot); var request = new Request(question, patient, sharpBot); var answer = sharpBot.Chat(request); return answer.Output; }
public void Initialize() { myBot.loadSettings(); AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(myBot); if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"/App_Data/Graphmaster.dat")) myBot.loadFromBinaryFile(AppDomain.CurrentDomain.BaseDirectory + @"/App_Data/Graphmaster.dat"); if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"/App_Data/Missy.db")) myBot.loadFromBinaryFile(AppDomain.CurrentDomain.BaseDirectory + @"/App_Data/Missy.db"); if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"/reasoner-3.3.2/reasoner-3.3.2/bin/su.dat")) myBot.loadFromBinaryFile(AppDomain.CurrentDomain.BaseDirectory + @"/reasoner-3.3.2/reasoner-3.3.2/bin/su.dat"); myBot.isAcceptingUserInput = false; loader.loadAIML(myBot.PathToAIML); myBot.isAcceptingUserInput = true; }
private void fromDefaultToolStripMenuItem_Click(object sender, EventArgs e) { try { AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.myBot); this.myBot.isAcceptingUserInput = false; loader.loadAIML(this.myBot.PathToAIML); this.myBot.isAcceptingUserInput = true; } catch (Exception ex) { this.richTextBoxOutput.Text += ex.Message + Environment.NewLine; } }
public void testGeneratePathWorksWithGoodDataWithWildcards() { this.mockBot = new Bot(); this.mockBot.loadSettings(); XmlDocument testDoc = new XmlDocument(); testDoc.Load(Path.Combine(this.mockBot.PathToAIML, "testWildcards.aiml")); XmlNode testNode = testDoc.LastChild.FirstChild.FirstChild; this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot); string result = this.mockLoader.generatePath(testNode, "testing _ 123 *", false); string expected = "test * 1 _ <that> testing * that _ 123 <topic> testing _ 123 *"; Assert.AreEqual(expected, result); }
public void testGeneratePathWorksWithNoThatTag() { this.mockBot = new Bot(); this.mockBot.loadSettings(); XmlDocument testDoc = new XmlDocument(); testDoc.Load(Path.Combine(this.mockBot.PathToAIML, "testNoThat.aiml")); XmlNode testNode = testDoc.LastChild.FirstChild; this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot); string result = this.mockLoader.generatePath(testNode, "*", false); string expected = "test 1 <that> * <topic> *"; Assert.AreEqual(expected, result); }
public void testGeneratePathWorksAsUserInput() { this.mockBot = new Bot(); this.mockBot.loadSettings(); XmlDocument testDoc = new XmlDocument(); testDoc.Load(Path.Combine(this.mockBot.PathToAIML, "testNoThat.aiml")); XmlNode testNode = testDoc.LastChild.FirstChild; this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot); string result = this.mockLoader.generatePath("This * is _ a pattern", "This * is _ a that", "This * is _ a topic", true); string expected = "This is a pattern <that> This is a that <topic> This is a topic"; Assert.AreEqual(expected, result); }
public chat() { chat_time.AutoReset = false; chat_time.Elapsed += stop_chat; chat_time.Enabled = false; still_chatting = false; chatting_nick = new List <string>(); myBot = new AIMLbot.Bot(); myBot.loadSettings(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "chat" + Path.DirectorySeparatorChar + "Settings.xml"); myUser = new User("chat_nick", myBot); AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(myBot); myBot.isAcceptingUserInput = false; loader.loadAIML(myBot.PathToAIML); myBot.isAcceptingUserInput = true; }
public chat() { chat_time.AutoReset = false; chat_time.Elapsed += stop_chat; chat_time.Enabled = false; still_chatting = false; chatting_nick = new List <string>(); myBot = new Bot(); myBot.loadSettings(); myUser = new User("chat_nick", myBot); AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(myBot); myBot.isAcceptingUserInput = false; loader.loadAIML(myBot.PathToAIML); myBot.isAcceptingUserInput = true; }
public ChatRobotOperator(string userName) { bot = new Bot(); bot.loadSettings(); user = new User(userName, bot); //try //{ AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(bot); bot.isAcceptingUserInput = false; loader.loadAIML(bot.PathToAIML); bot.isAcceptingUserInput = true; //} //catch (Exception ex) //{ // //this.outputRichTextBox.AppendText(ex.Message + Environment.NewLine); //} }
public chat() { chat_time.AutoReset = false; chat_time.Elapsed += stop_chat; chat_time.Enabled = false; still_chatting = false; chatting_nick = new List<string>(); myBot = new Bot(); myBot.loadSettings(); myUser = new User("chat_nick", myBot); AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(myBot); myBot.isAcceptingUserInput = false; loader.loadAIML(myBot.PathToAIML); myBot.isAcceptingUserInput = true; }
private bool LoadALICE() { try { Alice = new AIMLbot.Bot(); Alice.isAcceptingUserInput = false; Alice.loadSettings(); AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(Alice); Alice.isAcceptingUserInput = false; loader.loadAIML(Alice.PathToAIML); Alice.isAcceptingUserInput = true; return(true); } catch (Exception ex) { System.Console.WriteLine("Failed loading ALICE: " + ex.Message); return(false); } }
private void singleFileToolStripMenuItem_Click(object sender, EventArgs e) { try { FileInfo fi = new FileInfo(Path.Combine(Application.ExecutablePath, "aiml")); openFileDialogDump.InitialDirectory = fi.DirectoryName; openFileDialogDump.AddExtension = true; openFileDialogDump.DefaultExt = "aiml"; openFileDialogDump.FileName = "Reduce.aiml"; DialogResult dr = openFileDialogDump.ShowDialog(this); if (dr == DialogResult.OK) { AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.myBot); loader.loadAIMLFile(openFileDialogDump.FileName); } } catch (Exception ex) { this.richTextBoxOutput.Text += ex.Message + Environment.NewLine; } }
public Form2() { InitializeComponent(); this.inputTextBox.Focus(); myBot = new Bot(); myBot.loadSettings(); myUser = new User("DefaultUser", this.myBot); myBot.WrittenToLog += new Bot.LogMessageDelegate(myBot_WrittenToLog); try { AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.myBot); this.myBot.isAcceptingUserInput = false; loader.loadAIML(this.myBot.PathToAIML); this.myBot.isAcceptingUserInput = true; } catch (Exception ex) { this.outputRichTextBox.AppendText(ex.Message + Environment.NewLine); } }
private bool LoadALICE() { try { Alice = new Bot { isAcceptingUserInput = false }; string configFile = Path.Combine( Directory.GetCurrentDirectory(), "aiml_config", "Settings.xml"); Alice.loadSettings(configFile); var loader = new AIMLbot.Utils.AIMLLoader(Alice); Alice.isAcceptingUserInput = false; loader.loadAIML(Alice.PathToAIML); Alice.isAcceptingUserInput = true; return(true); } catch (Exception ex) { Console.WriteLine("Failed loading ALICE: " + ex.Message); return(false); } }
public void testGeneratePathWorksWithGoodDataWithWildcards() { this.mockBot = new Bot(); this.mockBot.loadSettings(); XmlDocument testDoc = new XmlDocument(); testDoc.Load(Path.Combine(this.mockBot.PathToAIML, "testWildcards.aiml")); XmlNode testNode = testDoc.LastChild.FirstChild.FirstChild; this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot); string result = this.mockLoader.generatePath(testNode, "testing _ 123 *", false); string expected = "test * 1 _ <that> testing * that _ 123 <topic> testing _ 123 *"; Assert.AreEqual(expected, result); }
private void singleFileToolStripMenuItem_Click(object sender, EventArgs e) { try { FileInfo fi = new FileInfo(Path.Combine(Application.ExecutablePath, "aiml")); openFileDialogDump.InitialDirectory = fi.DirectoryName; openFileDialogDump.AddExtension = true; openFileDialogDump.DefaultExt = "aiml"; openFileDialogDump.FileName = "Reduce.aiml"; DialogResult dr = openFileDialogDump.ShowDialog(this); if (dr == DialogResult.OK) { AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.myBot); this.myBot.isAcceptingUserInput = false; loader.loadAIMLFile(openFileDialogDump.FileName); this.myBot.isAcceptingUserInput = true; } } catch (Exception ex) { this.richTextBoxOutput.Text += ex.Message + Environment.NewLine; } }
public void testGeneratePathWorksWithNoThatTag() { this.mockBot = new Bot(); this.mockBot.loadSettings(); XmlDocument testDoc = new XmlDocument(); testDoc.Load(Path.Combine(this.mockBot.PathToAIML, "testNoThat.aiml")); XmlNode testNode = testDoc.LastChild.FirstChild; this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot); string result = this.mockLoader.generatePath(testNode, "*", false); string expected = "test 1 <that> * <topic> *"; Assert.AreEqual(expected, result); }
public void testGeneratePathWorksAsUserInput() { this.mockBot = new Bot(); this.mockBot.loadSettings(); XmlDocument testDoc = new XmlDocument(); testDoc.Load(Path.Combine(this.mockBot.PathToAIML, "testNoThat.aiml")); XmlNode testNode = testDoc.LastChild.FirstChild; this.mockLoader = new AIMLbot.Utils.AIMLLoader(this.mockBot); string result = this.mockLoader.generatePath("This * is _ a pattern", "This * is _ a that", "This * is _ a topic", true); string expected = "This is a pattern <that> This is a that <topic> This is a topic"; Assert.AreEqual(expected, result); }
private void LoadALICE() { try { Alice = new AIMLbot.Bot(); Alice.isAcceptingUserInput = false; Alice.loadSettings(); AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(Alice); Alice.isAcceptingUserInput = false; loader.loadAIML(Alice.PathToAIML); Alice.isAcceptingUserInput = true; } catch (Exception ex) { System.Console.WriteLine("Failed loading ALICE: " + ex.Message); } }
private void fromDefaultToolStripMenuItem_Click(object sender, EventArgs e) { try { AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.myBot); this.myBot.isAcceptingUserInput = false; loader.loadAIML(this.myBot.PathToAIML); this.myBot.isAcceptingUserInput = true; } catch (Exception ex) { this.richTextBoxOutput.Text += ex.Message + Environment.NewLine; } }