Ejemplo n.º 1
0
        //Validates the gender of the user through variable 'gender'
        //Then loads the chatbot knowledge base depending on user gender
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (gender == "")
            {
                MessageBox.Show("Please select a gender", "Warning!");
            }
            else
            {
                if (gender == "Male")
                {
                    Chatbot = new SynBot();
                    Chatbot.PackageManager.LoadFromString(File.ReadAllText("Knowledge.simlpk"));
                }
                else if (gender == "Female")
                {
                    Chatbot = new SynBot();
                    Chatbot.PackageManager.LoadFromString(File.ReadAllText("FemaleKnowledge.simlpk"));
                }

                //Outputs the reply from the chatbot into textbot
                var result = Chatbot.Chat(InputBox.Text);
                OutputBox.Multiline = true;
                OutputBox.Text      = string.Format("User: {0} \r\nBot: {1}\r\n{2}", InputBox.Text, result.BotMessage, OutputBox.Text);
                InputBox.Text       = string.Empty;
            }
        }
Ejemplo n.º 2
0
        //public Tuple<string, bool> boilDown(string sentence)
        public string boilDown(string sentence)
        {
            /*string[] splitSentence = sentence.Split(' ');
             * foreach (string str in splitSentence)
             * {
             *  if (refUserFile(str))
             *  {
             *      return new Tuple<string, bool>(str,true);
             *  }
             * }
             * return new Tuple<string, bool>(sentence, true);*/
            int    max     = -1;
            string maxFile = "";
            SynBot Chatbot;

            foreach (string fileName in directory)
            {
                Chatbot = new SynBot();
                Chatbot.PackageManager.LoadFromString(File.ReadAllText(fileName));
                var result = Chatbot.Chat(sentence);
                int test   = Convert.ToInt32(result.BotMessage());
                maxFile = max < test ? fileName : maxFile;
            }
            //return new Tuple<string,bool>(maxFile, true);
            return(maxFile);
        }
Ejemplo n.º 3
0
        public MessageForm(string jid, string domain)
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
            jidFrom    = jid;
            serverName = domain;

            this.Text          = "Chat with: " + jid;
            synBot             = new SynBot();
            botUser            = new BotUser(synBot, jid);
            synBot.Learning   += SynBot_Learning;
            synBot.Memorizing += synBot_Memorizing;
            synBot.Configuration.StoreVocabulary = true;
            synBot.Configuration.StoreExamples   = true;
            synBot.Learning   += SynBot_Learning;
            synBot.Memorizing += synBot_Memorizing;
            synBot.Configuration.StoreVocabulary = true;
            synBot.Configuration.StoreExamples   = true;
            //Load brain files(siml) here...
            Program.xclient.SendMessage(jidFrom + "@" + serverName, "Loading Brain please wait...");
            var simlPackage = File.ReadAllText("package\\projectamy.simlpk");

            synBot.PackageManager.LoadFromString(simlPackage);
            try
            {
                var fileLearn = File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "package\\Learned.siml"));
                synBot.AddSiml(fileLearn);
                Console.WriteLine("Loaded learning file...");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Project Amy has not learned anything new yet...");
            }
            try
            {
                //var fileMem = File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory() + "\\package", botUser.ID, "Memorized.siml"));
                //synBot.AddSiml(fileMem);
                var memPackage = File.ReadAllText("package\\" + jid + "\\memory.simlpk");
                synBot.PackageManager.LoadFromString(simlPackage);
                Console.WriteLine("Loaded personal user Memory file...");
            }
            catch (Exception ex)
            {
                Console.WriteLine("No memory file for user " + botUser.ID);
            }
            Program.xclient.SendMessage(jidFrom + "@" + serverName, "Loaded! You may now send me messages!");
        }
 public MainWindow()
 {
     InitializeComponent();
     Bot = new SynBot();
     DatabaseUtility = new DatabaseUtility();
     DatabaseUtility.Initialize();
     UpdateDataGrid("SELECT * From Employees");
     Bot.Sets.Add(new NameSet(DatabaseUtility));
     Bot.Sets.Add(new JobSet(DatabaseUtility));
     Bot.Sets.Add(new SalarySet(DatabaseUtility));
     Bot.Sets.Add(new AgeSet(DatabaseUtility));
     Bot.Sets.Add(new IdSet(DatabaseUtility));
     Bot.Adapters.Add(new SqlAdapter(this));
     var simlFiles = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "SIML"), "*.siml", SearchOption.AllDirectories);
     foreach (var simlDocument in simlFiles.Select(XDocument.Load))
     {
         Bot.AddSiml(simlDocument);
     }
     ExamplesBox.Text = Properties.Resources.Examples;
 }
Ejemplo n.º 5
0
 public Form1()
 {
     InitializeComponent();
     Chatbot = new SynBot();
     Chatbot.PackageManager.LoadFromString(File.ReadAllText("chatBot.simlpk"));
 }
Ejemplo n.º 6
0
 public ChatBotWindow()
 {
     InitializeComponent();
     Chatbot = new SynBot();
     Chatbot.PackageManager.LoadFromString(File.ReadAllText("Knowledge.simlpk"));
 }
 public void initiateSIML()
 {
     TIASimlBot = new SynBot();
     TIASimlBot.PackageManager.LoadFromString(File.ReadAllText("TIA.simlpk"));
 }
Ejemplo n.º 8
0
 public MainPage()
 {
     Chatbot = new SynBot();
     Chatbot.PackageManager.LoadFromString(File.ReadAllText("SIMLibouigPackage.simlpk"));
     this.InitializeComponent();
 }
Ejemplo n.º 9
0
        static void ConsoleInputThreadProc(object state)
        {
            xclient.Message += OnNewMessage;
            Console.WriteLine("ProjectAmy - Ver. 1.0");
            var synBot = new SynBot();

            Console.Write("Enter a username: "******"Enter A Password: "******"ProjectAmy - Ver. 1.0");
            Console.WriteLine();
            Console.WriteLine("Please wait, contacting XMPP Server...");
            try
            {
                xclient.Connect();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not connect to server, you can still chat in console though." + Environment.NewLine + ex.ToString());
            }
            if (xclient.Connected == true)
            {
                try
                {
                    xclient.Authenticate(user, pass);
                }
                catch (System.Security.Authentication.AuthenticationException ex)
                {
                    Console.WriteLine("Authentication failure!." + Environment.NewLine + ex.ToString());
                }

                if (xclient.Authenticated == true)
                {
                    Console.WriteLine("Logged into urgero.net:5222 xmpp protocol.");

                    //No error handlers yet, lets focus on OnNewMessage first...
                    //xclient.Error += OnError;
                }
            }
            Console.WriteLine();
            Console.WriteLine("Loading brain files, please wait...");
            Console.WriteLine();
            Console.WriteLine("-----------------------------------");
            synBot.Learning   += SynBot_Learning;
            synBot.Memorizing += synBot_Memorizing;
            synBot.Configuration.StoreVocabulary = true;
            synBot.Configuration.StoreExamples   = true;
            //Load brain files(siml) here...
            var simlPackage = File.ReadAllText("package\\projectamy.simlpk");

            synBot.PackageManager.LoadFromString(simlPackage);
            try
            {
                var fileLearn = File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "package\\Learned.siml"));
                synBot.AddSiml(fileLearn);
                Console.WriteLine("Loaded learning file...");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Project Amy has not learned anything new yet...");
            }
            try
            {
                //var fileMem = File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory() + "\\package", botUser.ID, "Memorized.siml"));
                //synBot.AddSiml(fileMem);
                var memPackage = File.ReadAllText("package\\" + user + "\\memory.simlpk");
                synBot.PackageManager.LoadFromString(simlPackage);
                Console.WriteLine("Loaded personal user Memory file...");
            }
            catch (Exception ex)
            {
                Console.WriteLine("No memory file for user " + botUser.ID);
            }

            bool isChat = true;

            var interactions = synBot.Stats.Interactions;
            var idleTime     = synBot.Stats.IdleTime;
            var loadTime     = synBot.Stats.LoadTime;
            var mappingTime  = synBot.Stats.MappingTime;
            var modelCount   = synBot.Stats.ModelCount;
            var vocabCount   = synBot.Stats.Vocabulary.Count();

            Console.WriteLine("Interactions: " + interactions);
            Console.WriteLine("LoadTime: " + loadTime);
            Console.WriteLine("Mapping Time: " + mappingTime);
            Console.WriteLine("Vocabulary Count: " + vocabCount);
            Console.WriteLine("Model count: " + modelCount);
            Console.WriteLine("-----------------------------------");
            Console.WriteLine();
            Console.WriteLine("Brain Loaded.");
            //Actual Chatting Session:
            if (xclient.Connected == false)
            {
                while (isChat == true)
                {
                    Console.Write("Enter Message: ");
                    String message = Console.ReadLine();
                    if (message == "exit")
                    {
                        if (xclient.Connected == true)
                        {
                            xclient.Dispose();
                        }
                        //var settings = synBot.Settings.GetDocument();
                        //settings.Save("package\\BotSettings.siml");
                        Console.WriteLine("--------------------");
                        Console.WriteLine("Writing memory to package for later...");

                        //For some reason the following does not work.
                        try
                        {
                            var elementList = new List <XDocument>();
                            foreach (var simlFile in Directory.GetFiles(@"package\\" + user, "*.siml"))
                            {
                                var simlElement = XElement.Load(simlFile);
                                elementList.Add(simlElement.Document);
                            }
                            var xdoc          = new XDocument(elementList);
                            var packageString = synBot.PackageManager.ConvertToPackage(elementList);
                            File.WriteAllText(@"package\\" + user + "\\memory.simlpk", packageString);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("ERROR: " + ex.ToString());
                            Console.ReadLine();
                        }

                        Console.WriteLine("--------------------");
                        Environment.Exit(0);
                    }
                    var chatReq    = new ChatRequest(message, botUser);
                    var chatResult = synBot.Chat(chatReq);
                    if (chatResult.Success)
                    {
                        Console.WriteLine("Amy: " + chatResult.BotMessage);
                    }
                }
            }
        }
Ejemplo n.º 10
0
 private void femaleBtn_CheckedChanged(object sender, EventArgs e)
 {
     gender  = "Female";
     Chatbot = new SynBot();
     Chatbot.PackageManager.LoadFromString(File.ReadAllText("FemaleKnowledge.simlpk"));
 }