protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var bot = new OscovaBot(); bot.Dialogs.Add(new HelloBotDialog()); bot.Trainer.StartTraining(); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.MyButton); var input = FindViewById <EditText>(Resource.Id.editText1); var output = FindViewById <EditText>(Resource.Id.editText2); bot.MainUser.ResponseReceived += (sender, args) => { output.Text = $"Bot: {args.Response.Text}"; }; button.Click += delegate { var result = bot.Evaluate(input.Text); result.Invoke(); }; }
private static void Main(string[] args) { var bot = new OscovaBot(); // License is required, see https://developer.syn.co.in/tutorial/bot/activate-license.html //bot.Configuration.ProcessingMode = ProcessingMode.Deep; Console.WriteLine("Loading WordNet"); LoadWordNet(bot); Console.WriteLine("Loading word vectors"); LoadWordVectors(bot); Console.WriteLine("Adding dialogs"); bot.Dialogs.Add(new HelloBotDialog()); bot.Dialogs.Add(new AppDialog()); //bot.Dialogs.Add(new MyDialog()); Console.WriteLine("Training the model"); bot.Trainer.StartTraining(); Console.WriteLine("Ready!"); bot.MainUser.ResponseReceived += (sender, eventArgs) => { Console.WriteLine(eventArgs.Response.Text); }; while (true) { var request = Console.ReadLine(); var evaluationResult = bot.Evaluate(request); evaluationResult.Invoke(); } }
static void Main(string[] args) { var lblnSair = false; while (!lblnSair) { var bot = new OscovaBot(); bot.Dialogs.Add(new ChatBotDialog()); bot.Trainer.StartTraining(); bot.MainUser.ResponseReceived += (sender, eventArgs) => { Console.WriteLine($"Panelinha: {eventArgs.Response.Text}"); }; Console.Write("Usuário: "); var message = Console.ReadLine(); var result = bot.Evaluate(message); result.Invoke(); if (message.Equals("sair")) { lblnSair = true; } } }
private dynamic OnPostText(dynamic o) { OscovaBot bot = TvBot.Instance; dynamic result = bot.Evaluate(o.text); result.Invoke(); return(result); }
public String reponseQuestion(String req) { EvaluationResult ev = ob.Evaluate(req); ev.Invoke(); Response resp = ob.MainUser.Responses.First <Response>(); return(resp.Text); }
public String answer(String message) { EvaluationResult ev = bot.Evaluate(message); ev.Invoke(); Response resp = bot.MainUser.Responses.First <Response>(); String ans = resp.Text; return(ans); }
public void HandleRequest(string expression) { try { var evaluationResult = _bot.Evaluate(expression); evaluationResult.Invoke(); } catch (Exception ex) { _receiver.Invoke(new AssistantResponse($"При выполнении команды произошла ошибка!")); Console.WriteLine(ex.Message); } }
public void SendMessageToBot() { var userMessage = chatBox.text; if (!string.IsNullOrEmpty(userMessage)) { Debug.Log($"OscovaBot:[USER] {userMessage}"); AddMessage($"User: {userMessage}", MessageType.User); var request = MainBot.MainUser.CreateRequest(userMessage); var evaluationResult = MainBot.Evaluate(request); evaluationResult.Invoke(); chatBox.Select(); chatBox.text = ""; } }
static void Main(string[] args) { var bot = new OscovaBot(); bot.ImportWorkspace(@"C:\Users\aykut\OneDrive\Documents\bot1.west"); bot.Trainer.StartTraining(); bot.MainUser.ResponseReceived += (sender, eventArgs) => { Console.WriteLine($"Bot: {eventArgs.Response.Text}"); }; while (true) { var request = Console.ReadLine(); var evaluationResult = bot.Evaluate(request); evaluationResult.Invoke(); } }
/// <summary> /// This function sends a message /// </summary> public void Send() { if (!string.IsNullOrEmpty(TextToSend)) { var msgModel = new ChatMessageModel() { Text = TextToSend, User = App.User }; //This adds a new message to the messages collection Messages.Add(msgModel); var result = chatbot.Evaluate(TextToSend); result.Invoke(); //Removes the text in the Entry after message is sent TextToSend = string.Empty; } }
private static void Main(string[] args) { var bot = new OscovaBot(); bot.Dialogs.Add(new HelloBotDialog()); bot.Dialogs.Add(new AppDialog()); bot.Trainer.StartTraining(); bot.MainUser.ResponseReceived += (sender, eventArgs) => { Console.WriteLine(eventArgs.Response.Text); }; while (true) { var request = Console.ReadLine(); var evaluationResult = bot.Evaluate(request); evaluationResult.Invoke(); } }
public void SendMessageToBot() { var userMessage = chatBox.text; if (!string.IsNullOrEmpty(userMessage)) { Debug.Log($"OscovaBot:[USER] {userMessage}"); AddMessage($"User: {userMessage}", MessageType.User); //Create a request for bot to process. var request = MainBot.MainUser.CreateRequest(userMessage); //Evaluate the request (Compute NLU - Natural Language Understanding) var evaluationResult = MainBot.Evaluate(request); //Invoke the best suggested intent found. This is compel a response generation. evaluationResult.Invoke(); chatBox.Select(); chatBox.text = ""; } }
protected override void OnActivityResult(int requestCode, Android.App.Result resultVal, Intent data) { var bot = new OscovaBot(); bot.Dialogs.Add(new HelloBotDialog()); bot.Trainer.StartTraining(); if (requestCode == VOICE) { if (resultVal == Android.App.Result.Ok) { var matches = data.GetStringArrayListExtra(RecognizerIntent.ExtraResults); if (matches.Count != 0) { string textInput = input.Text + matches[0]; // limit the output to 500 characters if (textInput.Length > 500) { textInput = textInput.Substring(0, 500); } input.Text = textInput; var result = bot.Evaluate(textInput); result.Invoke(); CrossTextToSpeech.Current.Speak(output.Text); } else { input.Text = "No speech was recognised"; } // change the text back on the button button.Text = "Start Recording"; } } base.OnActivityResult(requestCode, resultVal, data); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); isRecording = false; // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var bot = new OscovaBot(); bot.Dialogs.Add(new HelloBotDialog()); bot.Trainer.StartTraining(); string rec = Android.Content.PM.PackageManager.FeatureMicrophone; if (rec != "android.hardware.microphone") { // no microphone, no recording. Disable the button and output an alert var alert = new AlertDialog.Builder(button.Context); alert.SetTitle("You don't seem to have a microphone to record with"); alert.SetPositiveButton("OK", (sender, e) => { input.Text = "No microphone present"; button.Enabled = false; return; }); alert.Show(); } // Get our button from the layout resource, // and attach an event to it button = FindViewById <Button>(Resource.Id.MyButton); input = FindViewById <EditText>(Resource.Id.editText1); output = FindViewById <EditText>(Resource.Id.editText2); bot.MainUser.ResponseReceived += (sender, args) => { output.Text = $"Bot: {args.Response.Text}"; }; button.Click += delegate { var result = bot.Evaluate(input.Text); result.Invoke(); CrossTextToSpeech.Current.Speak(output.Text); // change the text on the button button.Text = "End Recording"; isRecording = !isRecording; if (isRecording) { // create the intent and start the activity var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech); voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); // put a message on the modal dialog voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt, Application.Context.GetString(Resource.String.messageSpeakNow)); // if there is more then 1.5s of silence, consider the speech over voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500); voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500); voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000); voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1); // you can specify other languages recognised here, for example // voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.German); // if you wish it to recognise the default Locale language and German // if you do use another locale, regional dialects may not be recognised very well voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default); StartActivityForResult(voiceIntent, VOICE); } }; }
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); } }
//Function to send the message to the OSCOVA bot //It will then review all the intents in the loaded .west/.json workspace //Once it found the nearest match, it will send the response public void SendMessageToBot(string inputField) { var userMessage = inputField; if (!string.IsNullOrEmpty(userMessage)) { Debug.Log($"OscovaBot:[USER] {userMessage}"); AddMessage($"User: {userMessage}", MessageType.User); //Create a request for bot to process. var request = MainBot.MainUser.CreateRequest(userMessage); //Evaluate the request (Compute NLU - Natural Language Understanding) var evaluationResult = MainBot.Evaluate(request); //Invoke the best suggested intent found. This is compel a response generation. evaluationResult.Invoke(); //Get the intent name to change the Tobor expression IntentResult intentResult = evaluationResult.SuggestedIntent; string intentName = intentResult.Name.ToString(); Debug.Log("Intent Name: " + intentName); //Phrase will be loading according to the current date //Different phrases loads different JSON // if intentname contain "sad", show sad, contain "happy" show happy(check dialogs name) eg: happy_dialog_ep1.happy //Currently Tobor only have "Greeting" and "Feeling" dialogs -> loads "Happy" expression and "Happy" body movement ExpressionAnim = FindObjectOfType <ExpressionControl>(); toborBodyAnimator = GameObject.FindGameObjectWithTag("BodyAnimator").GetComponent <Animator>(); if (phaseInitiated < 3) { if (intentName == "BotDialog.DefaultFallback") { ExpressionAnim.SetExpression(SAD_STATE_INDEX); StartCoroutine(BackToBodyNormal(3, NORMAL_STATE_INDEX, NORMAL_STATE_INDEX)); } else { ExpressionAnim.SetExpression(NORMAL_STATE_INDEX); } } else { if (intentName == "BotDialog.DefaultFallback") { ExpressionAnim.SetExpression(SAD_STATE_INDEX); toborBodyAnimator.SetInteger(BODY_ANIM_STATE, SAD_STATE_INDEX); StartCoroutine(BackToBodyNormal(3, SAD_BACKNORMAL_STATE_INDEX, NORMAL_STATE_INDEX)); } else if (intentName.Contains("feeling")) { ExpressionAnim.SetExpression(HAPPY_STATE_INDEX); toborBodyAnimator.SetInteger(BODY_ANIM_STATE, HAPPY_STATE_INDEX); StartCoroutine(BackToBodyNormal(3, HAPPY_BACKNORMAL_STATE_INDEX, NORMAL_STATE_INDEX)); } else { ExpressionAnim.SetExpression(NORMAL_STATE_INDEX); toborBodyAnimator.SetInteger(BODY_ANIM_STATE, NORMAL_STATE_INDEX); } } chatBox.text = ""; // } } }