public string boilDown(string sentence) { int max = -1; string maxFile = ""; string path = "SynBotDir"; foreach (string fileName in System.IO.Directory.EnumerateFiles(path)) //maybe don't hard code { Console.WriteLine(fileName + "file"); SimlBot Chatbot = new SimlBot(); Chatbot.PackageManager.LoadFromString(File.ReadAllText(fileName)); var result = Chatbot.Chat(sentence); string outString = result.BotMessage; if (!outString.Contains(";")) { continue; } string[] output = result.BotMessage.Split(';'); var lastString = output[output.Length - 2]; var response = lastString.Split(':'); int test = Convert.ToInt32(response[0]); maxFile = max < test ? response[1] : maxFile; max = max < test ? test : max; } //return new Tuple<string,bool>(maxFile, true); return(maxFile); }
public BotResponseGenerator(IAdaptersRepository adaptersRepository, ISimlPackageLoader simlPackageLoader, IInputNormalizer inputNormalizer) { _inputNormalizer = inputNormalizer; _simlBot = new SimlBot(); _simlBot.PackageManager.LoadFromString(simlPackageLoader.LoadSimlPackage()); _simlBot.Adapters.AddRange(adaptersRepository.GetAdapters()); }
public static async Task LoadLibraryAsync() { if (_siml != null) { return; } await Task.Run(() => { _log.Debug("Creating new chatbot..."); _yandex = new Yandex(); _siml = new SimlBot(); var simlDir = Program.FilePathInData("Siml"); var simlFiles = Directory.GetFiles(simlDir, "*.siml", SearchOption.AllDirectories); foreach (var simlFile in simlFiles) { var name = Path.GetFileName(simlFile); try { _log.Debug($"Loading {name}"); var simlDocument = XDocument.Load(simlFile); _siml.Import(simlDocument); } catch (Exception e) { _log.Error(e.Message); } } }); }
public MainWindow() { InitializeComponent(); loadState(); simlBot = new SimlBot(); simlBot.PackageManager.LoadFromString(File.ReadAllText("Knowledge.simlpk")); listen(); }
public static string GetResponse(string msg, string user, string languageFile) { var simlBot = new SimlBot(); simlBot.PackageManager.LoadFromString(File.ReadAllText(languageFile)); var result = simlBot.Chat(msg); // save it to database //db.InsertChat(msg, result.BotMessage, user); return(result.BotMessage); }
public DiscoBot() { bot = new DiscordClient(); chatBot = new SimlBot(); onlineUsers = new String[50]; userIds = new User[50]; botFilename = "log_" + DateTime.Now.Millisecond + ".txt"; chatBot.PackageManager.LoadFromString(File.ReadAllText("bob.simlpk")); }
public SIMLHub_Old() : base("SIMLHub") { bot = new SimlBot(); // Soon it will be substracted this.adapterCount = bot.Adapters.Count; // Add all adapters pluginAdapterPathAndTypes = helper.GetAllSIMLHubPluginIndexAdapterPathAndTypes(); Console.Write("[SIMLHub] Adapters loading : "); foreach (var adapterPair in pluginAdapterPathAndTypes) { Assembly assembly = Assembly.LoadFrom(adapterPair.Key); foreach (var typename in adapterPair.Value) { try { IAdapter adapter = (IAdapter)assembly.CreateInstance(typename); AbstractPlugin simlHubPlugin = (AbstractPlugin)adapter; this.Hub.PassThrough(simlHubPlugin.Hub); // Add to bot in not null if (adapter != null) { bot.Adapters.Add(adapter); } } catch { /*Ignore*/ } } } Console.WriteLine("success"); // Now final value is set this.adapterCount = bot.Adapters.Count - this.adapterCount; // Add all index.siml files Console.Write("[SIMLHub] Index siml merge : "); string mergedIndexSimlPackage = helper.GetAllIndexSimlPackage(); Console.WriteLine("success"); Console.Write("[SIMLHub] Merged index siml : "); bot.PackageManager.LoadFromString(mergedIndexSimlPackage); Console.WriteLine("success"); // Subscribe to IUserResponse for input hub.Subscribe <IUserResponse>(this.GetBotReponse); }
public MainWindow() { InitializeComponent(); Chatbot = new SimlBot(); Chatbot.PackageManager.LoadFromString(File.ReadAllText("Knowledge.simlpk")); ColorBOT = "#FF4A4B53"; ColorUser = "******"; FontColor = "#FFFFFF"; AppWindow = this; settwindow = new Settings(); fontSize = 14; GoldBOT = "botmsg"; }
public override void Dispose() { foreach (var plugin in simlPlugins) { plugin.Dispose(); } helper = null; utility = null; bot = null; currentUser = null; pluginAdapterPathAndTypes?.Clear(); pluginAdapterPathAndTypes = null; }
private static void LaunchSimlBot() { var websiteUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority); var simlBot = new SimlBot(); _simlBotChannel = new WidgetChannel <SimlBot>(simlBot) { ServiceUrl = websiteUrl + "/BotService.aspx", ResourceUrl = websiteUrl + "/BotResource", }; using (var webClient = new WebClient()) { var result = webClient.DownloadString(_simlBotChannel.ResourceUrl + "//package.txt"); simlBot.PackageManager.LoadFromString(result); } }
public MainWindow() { InitializeComponent(); Bot = new SimlBot(); 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; }
string getResponse(string textReceived) { if (hasBotBeenCreated == false) { simlBot = new SimlBot(); botUser = simlBot.CreateUser(); var packageString = File.ReadAllText("SIMLPackage.simlpk"); simlBot.PackageManager.LoadFromString(packageString); } var chatRequest = new ChatRequest(textReceived, botUser); //These two can't access the objects created above var chatResult = simlBot.Chat(chatRequest); if (chatResult.Success) { var botMessage = chatResult.BotMessage; return(botMessage); } else { return("I don't have a response for that"); } }
public SIMLHub() : base("SIMLHub") { bot = new SimlBot(); // Soon it will be substracted adapterCount = 0; // Add all adapters pluginAdapterPathAndTypes = helper.GetAllSIMLHubPluginIndexAdapterPathAndTypes(); Console.ForegroundColor = ConsoleColor.Magenta; Console.Write("[SIMLHub] Adapters loading : "); Console.ResetColor(); simlPlugins = new List <AbstractPlugin>(); int botAdapterCount = 0; foreach (var adapterPair in pluginAdapterPathAndTypes) { Assembly assembly = Assembly.LoadFrom(adapterPair.Key); foreach (var typename in adapterPair.Value) { try { IAdapter adapter = (IAdapter)assembly.CreateInstance(typename); AbstractPlugin simlHubPlugin = (AbstractPlugin)adapter; simlPlugins.Add(simlHubPlugin); Hub.PassThrough(simlHubPlugin.Hub); // Add to bot in not null if (adapter != null) { bot.Adapters.Add(adapter); botAdapterCount++; } } catch { /*Ignore*/ } } } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("success"); Console.ResetColor(); // Now final value is set adapterCount = botAdapterCount; Console.WriteLine("[SIMLHub] SIMLHub Plugins count: " + adapterCount); // Add all index.siml files Console.ForegroundColor = ConsoleColor.Magenta; Console.Write("[SIMLHub] Index siml merge : "); Console.ResetColor(); string mergedIndexSimlPackage = helper.GetAllIndexSimlPackage(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("success"); Console.ResetColor(); Console.ForegroundColor = ConsoleColor.Magenta; Console.Write("[SIMLHub] Merged index siml : "); Console.ResetColor(); bot.PackageManager.LoadFromString(mergedIndexSimlPackage); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("success"); Console.ResetColor(); // Subscribe to IUserResponse for input hub.Subscribe <IUserResponse>(GenerateAndPublishBotResponse); hub.Subscribe <AllPluginsLoaded>(AllPluginsLoadedCallback); // Subscribe to IMachineMessage for processing machine generated message hub.Subscribe <IMachineMessage>(MakeMachineMessageUserFriendly); }
public Agent() { Chatbot = new SimlBot(); Chatbot.PackageManager.LoadFromString(File.ReadAllText("Knowledge.simlpk")); }
public Synbot(string userid, string botpath, string packagename, string botsavepath, string robottype , EZ_Builder.Scripting.Executor executor, string defautbotname, string language) { string packageString = ""; string pathbotpk = botpath + packagename + ".simlpk"; string pathbotsource = botpath; _executor_bot = executor; this.simlBot = new SimlBot(); simlBot.Adapters.Add(new EzvarAdapter()); simlBot.Adapters.Add(new EzcmdAdapter()); simlBot.Adapters.Add(new CompareAdapter()); simlBot.Adapters.Add(new VaropAdapter()); simlBot.Adapters.Add(new LearnAdapter()); Simladaptators.Simladaptators.adaptators.Add(this.simlBot); UserSIMLadaptators.Simladaptators.adaptators.Add(this.simlBot); this.botUser = simlBot.MainUser; //this.botUser = simlBot.CreateUser(userid); // Recreate package var elementList = new System.Collections.Generic.List <XDocument>(); foreach (var simlFile in Directory.GetFiles(pathbotsource, "*.siml")) { var simlElement = XDocument.Load(simlFile); elementList.Add(simlElement); } string pathsettings = pathbotsource + @"\" + "Settings" + @"\"; if (Directory.Exists(pathsettings)) { foreach (var simlFile in Directory.GetFiles(pathsettings)) { var simlElement = XDocument.Load(simlFile); elementList.Add(simlElement); } } var packageref = simlBot.PackageManager.ConvertToPackage(elementList); File.WriteAllText(pathbotpk, packageref); /// Load SIML Package file var t = Task.Run(() => packageString = File.ReadAllText(pathbotpk)); t.Wait(); this.simlBot.PackageManager.LoadFromString(packageString); this.nomsave = userid + "-Settings.siml"; this.useridbot = userid; this.botsavepath = botsavepath; refbot = this; path_bot = botpath; // attach event handler for the learning event of the bot this.simlBot.Learning += SimlBot_Learning; // attach event handler for the memorizing event of the bot this.simlBot.Memorizing += simlBot_Memorizing; Bot_Load(this.botsavepath); /// Extract Bot Name and User Name in settings bot_name = simlBot.Settings["Name"].Value; user_name = botUser.Settings["Name"].Value; /// Set Bot settings for robot type parameter botUser.Settings[botrobottype_variable].Value = robottype; /// Set Bot settings for language parameter botUser.Settings[botlanguage_variable].Value = language.Substring(0, 2); if (user_name == null) { user_name = string.Empty; botUser.Settings["Name"].Value = user_name; } /// If Name is not initialized in bot settings intialize it to detaut robot name if (bot_name == null || bot_name == string.Empty) { simlBot.Settings["Name"].Value = defautbotname; bot_name = defautbotname; } //Events to detect change in Bot Name and User Name // simlBot.Settings["Name"].Changed += (sender, args) => { Synbot.bot_name = simlBot.Settings["Name"].Value; }; botUser.Settings["Name"].Changed += (sender, args) => { Synbot.user_name = botUser.Settings["Name"].Value; }; }
public Bot() { //InitializeComponent(); Chatbot = new SimlBot(); Chatbot.PackageManager.LoadFromString(File.ReadAllText("Knowledge.simlpk")); }