Beispiel #1
0
        private static OscovaBot InitBot()
        {
            var bot = new OscovaBot();

            bot.CreateRecognizer <VolumeDirection>("volumeDirection");
            bot.CreateRecognizer <Direction>("direction");
            bot.CreateRecognizer <StationDirection>("stationDirection");
            bot.CreateRecognizer("volumeAddress", new[] { "Lautstärke", "Pegel", "Volume" });
            bot.CreateRecognizer("stationAddress", new[] { "Sender", "Kanal", "Fernsehsender", "Fernsehkanal", "TV-Sender", "Programm" });
            bot.Recognizers.Add(new StationRecognizer(() => TvControlViewModel.Current.TvStations));

            bot.Dialogs.Add(new StationDialog());
            bot.Dialogs.Add(new VolumeDialog());

            bot.Trainer.StartTraining();
            return(bot);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("ru-RU");

            var dbContext      = new NureBotDbContext(false);
            var unityContainer = new UnityContainer();

            dbContext.Database.Initialize(true);
            ContainerBoostraper.RegisterTypes(unityContainer, dbContext, "356520093:AAGKBe8YFpR5_5WIkGfoeRbdTMuOKE2O9GQ");

            Bot               = unityContainer.Resolve <TelegramBotClient>();
            UService          = unityContainer.Resolve <IUserService>();
            RecognitionSystem = unityContainer.Resolve <OscovaBot>();

            Console.Title = Bot.GetMeAsync().Result.Username;

            Bot.OnMessage      += Bot_OnMessage;
            Bot.OnReceiveError += Bot_OnReceiveError;

            RecognitionSystem.Dialogs.Add(new CistDialog());
            RecognitionSystem.Dialogs.Add(new WeatherDialog());

            RecognitionSystem.MainUser.Context.SharedData.Add(Bot);
            RecognitionSystem.MainUser.Context.SharedData.Add(UService);
            RecognitionSystem.Language.Stemmer   = new RussianStemmer();
            RecognitionSystem.Language.StopWords = StopWordsGenerator.GenerateRussianStopWords();

            RecognitionSystem.Trainer.StartTraining();
            RecognitionSystem.Recognizers.Clear();
            RecognitionSystem.Recognizers.Add(new RuDateRecognizer());
            RecognitionSystem.Language.Culture.DateTimeFormat =
                CultureInfo.GetCultureInfo("ru-RU").DateTimeFormat;
            RecognitionSystem.Recognizers.Add(new GroupRecognizer());
            RecognitionSystem.CreateRecognizer("teacherName", new Regex(@"[А-Яа-я]+ [А-Яа-я]\.? [А-Яа-я]\.?"));


            RecognitionSystem.MainUser.ResponseReceived += async(sender, arg) =>
            {
                var msg = JsonConvert.DeserializeObject <MessageTransfer>(arg.Response.Text);

                await Bot.SendTextMessageAsync(msg.ChatId, msg.Message, replyMarkup : msg.ReplyMarkup);
            };


            Bot.SetWebhookAsync();
            Bot.StartReceiving();

            Console.BackgroundColor = ConsoleColor.DarkGreen;
            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine(@"Service started");
            Console.WriteLine(@"Press Enter to Stop Service!");
            Console.ReadLine();
            Bot.StopReceiving();

            dbContext.Dispose();
            unityContainer.Dispose();
        }
Beispiel #3
0
        public MainWindow()
        {
            InitializeComponent();

            Bot = new OscovaBot();


            Bot.MainUser.ResponseReceived += (sender, args) =>
            {
                ResponseLabel.Content = args.Response.Text;
            };

            DatabaseUtility = new DatabaseUtility(this);
            DatabaseUtility.Initialize();
            UpdateDataGrid("SELECT * From Employees");

            Bot.MainUser.Context.SharedData.Add(DatabaseUtility);

            CreateNameParser();
            CreateJobParser();

            Bot.CreateRecognizer("set", new[] { "change", "update", "set" });
            Bot.CreateRecognizer("property", new[] { "id", "name", "job", "age", "salary" });
            Bot.CreateRecognizer("equality", new[] { "greater than", "less than", "equal to", "not equal to", "greater than or equal to", "less than or equal to" });

            //Add all required dialogs.
            Bot.Dialogs.Add(new DatabaseGenericDialog());
            Bot.Dialogs.Add(new DatabaseUpdateByNameDialog());
            Bot.Dialogs.Add(new DatabaseUpdateByIdDialog());
            Bot.Dialogs.Add(new DatabaseEnquiryDialog());
            Bot.Dialogs.Add(new DatabaseSuperlativeDialog());

            Bot.Language.Filters.AddWordFilter("=", "equal to");
            Bot.Language.Filters.AddWordFilter(">", "greater than");
            Bot.Language.Filters.AddWordFilter("<", "less than");
            Bot.Language.Filters.AddWordFilter(">=", "greater than or equal to");
            Bot.Language.Filters.AddWordFilter("<=", "less than or equal to");
            Bot.Language.Filters.AddWordFilter("!=", "not equal to");

            //Finally Train the Bot.
            //var data = Bot.Trainer.GetTrainingData();
            //data.Save(@"d:\training-data.xml");
            Bot.Trainer.StartTraining();
        }
Beispiel #4
0
        public ChatBotC()
        {
            ob = new OscovaBot();
            //Ajouter dialogue (base de connaissane)
            ob.Dialogs.Add(new BaseConnaissance());
            //Connexion avec bd
            ConnectionavecBase conB = new ConnectionavecBase();

            ob.MainUser.Context.SharedData.Add(conB);
            ob.CreateRecognizer("Categorie", new[] { "T-Shirt", "Short", "Survêtement", "Gilet", "Jacket", "Veste", "Tops", "Robes", "Jupes", "Jeans", "Pantalons", "Accessoires", "Chaussures" });
            ob.Trainer.StartTraining();
        }
Beispiel #5
0
        private static void LaunchOscovaBot()
        {
            var websiteUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
            var oscovaBot  = new OscovaBot();

            oscovaBot.Dialogs.Add(new HelloBotDialog());
            oscovaBot.CreateRecognizer("start", new Regex(@"(?<!/)(/(?:start))(?(?<=\w)\b)", RegexOptions.IgnoreCase));
            oscovaBot.Trainer.StartTraining();

            _oscovaBotChannel = new WidgetChannel <OscovaBot>(oscovaBot)
            {
                ServiceUrl  = websiteUrl + "/BotService.aspx",
                ResourceUrl = websiteUrl + "/BotResource",
            };
        }
Beispiel #6
0
        public Judi()
        {
            bot = new OscovaBot();
            bot.Dialogs.Add(new AppDialog());

            dbutility = new DataBaseUtility();
            dbutility.init();
            bot.MainUser.Context.SharedData.Add(dbutility);
            bot.CreateRecognizer("message", new[] { "this is a message" });
            bot.CreateRecognizer("price", new[] { "price" });
            bot.CreateRecognizer("action", new[] { "show", "display", "show me, give me" });
            bot.CreateRecognizer("qteQuestions", new[] { "do you have", "have you", "how many" });
            bot.CreateRecognizer("greeting", new[] { "hello", "hi", "good morning", "good afternoon", "good evening" });
            String[] st = dbutility.categoryDescriptions();
            String[] pl = dbutility.productLib();
            bot.CreateRecognizer("category", st);
            bot.CreateRecognizer("libelle", pl);

            bot.Trainer.StartTraining();
        }
Beispiel #7
0
        public void Initialize()
        {
            try
            {
                Employees.Clear();
                FullEmployeeList.Clear();
                Input = string.Empty;

                var sheet = Globals.ThisAddIn.Application.ActiveSheet as Worksheet;

                var columnCount = sheet?.UsedRange.Columns.Count;
                var rowCount    = sheet?.UsedRange.Rows.Count;

                var columnNameIndexTable = new Dictionary <int, string>();

                //Add column names and index.
                for (var i = 1; i <= columnCount; i++)
                {
                    var cell = sheet.UsedRange.Cells[1, i] as Range;
                    if (cell != null)
                    {
                        columnNameIndexTable.Add(i, cell.Value.ToString());
                    }
                }

                //Create employees list from row data.
                for (var r = 2; r <= rowCount; r++)
                {
                    var employee = new Employee();
                    for (var c = 1; c <= columnCount; c++)
                    {
                        var cell            = sheet.UsedRange.Cells[r, c] as Range;
                        var columnName      = columnNameIndexTable[c].ToLower();
                        var stringCellValue = cell?.Value.ToString();
                        if (stringCellValue == null)
                        {
                            break;
                        }
                        if (columnName == "id")
                        {
                            employee.Id = int.Parse(stringCellValue);
                        }
                        if (columnName == "salary")
                        {
                            employee.Salary = int.Parse(stringCellValue);
                        }
                        if (columnName == "age")
                        {
                            employee.Age = int.Parse(stringCellValue);
                        }
                        if (columnName == "name")
                        {
                            employee.Name = stringCellValue;
                        }
                        if (columnName == "role")
                        {
                            employee.Role = stringCellValue;
                        }
                    }
                    FullEmployeeList.Add(employee);
                }


                Bot = new OscovaBot();
                Bot.MainUser.Context.SharedData.Add(this);
                Bot.Dialogs.Add(new DatabaseGenericDialog());
                Bot.Dialogs.Add(new DatabaseEnquiryDialog());
                Bot.Dialogs.Add(new DatabaseSuperlativeDialog());

                Bot.MainUser.ResponseReceived += (sender, args) =>
                {
                    Output = args.Response.Text;
                };

                Task.Run(() =>
                {
                    Bot.CreateRecognizer("property", new[] { "ID", "Name", "Role", "Age", "Salary" });
                    Bot.CreateRecognizer("role", new[] { "CEO", "Manager", "Admin", "Engineer", "Tech", "Support" });
                    AddEmployeeNameRecognizer();
                    Bot.Trainer.StartTraining();
                });

                _sendAction = () =>
                {
                    Output = string.Empty;
                    var evaluationResult = Bot.Evaluate(Input);
                    evaluationResult.Invoke();
                    Input = string.Empty;
                };
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }