public T Deserialize <T>(IntentRecognitionResult intent) { var json = intent.Properties.GetProperty( PropertyId.LanguageUnderstandingServiceResponse_JsonResult); return(JsonConvert.DeserializeObject <T>(json)); }
public IntentRecognitionResult Parse(LuisResponseDto response) { var result = new IntentRecognitionResult(); var intent = response.MostProbableIntent; result.OriginalIntent = intent; result.IntentLabel = intent.IntentLabel; var action = intent.Actions?.FirstOrDefault(a => a.Triggered); if (action != null) { result.PropertyParameter = action.Parameters.FirstOrDefault(p => p.Value != null && p.Value.Any(v => v.Type == "Property"))? .Value.First() .Entity; result.RoomParameter = action.Parameters.FirstOrDefault(p => p.Value != null && p.Value.Any(v => v.Type == "Room"))?.Value.First().Entity; result.ThingParameter = action.Parameters.FirstOrDefault(p => p.Value != null && p.Value.Any(v => v.Type == "Thing"))?.Value.First().Entity; var numericParameter = action.Parameters.FirstOrDefault(p => p.Value != null && p.Value.Any(v => v.Type == "builtin.number"))? .Value.First() .Entity; if (numericParameter != null) { result.NumericParameter = int.Parse(numericParameter); } } return(result); }
public override void Do(IntentRecognitionResult intent) { var soundFileName = ""; switch (intent.IntentId) { case "ASB-digital-comms-team-perf": soundFileName = "TeamPerf"; break; case "ASB-digital-comms-highlight": soundFileName = "Highlight"; break; case "ASB-digital-comms-squad-mvp": soundFileName = "SquadMvp"; break; case "ASB-digital-comms-enjoyed-most": soundFileName = "EnjoyedMost"; break; case "ASB-digital-comms-still-need-host-RCU": soundFileName = "StillNeedHostRCU"; break; case "ASB-digital-comms-financial-climate": soundFileName = "MachineOverLords"; break; case "ASB-digital-comms-terminator": soundFileName = "Terminator"; break; case "ASB-digital-comms-universe-muscles": soundFileName = "MrUniverseMuscles"; break; case "ASB-digital-comms-shut-you-down": soundFileName = "IWillBeBack"; break; case "ASB-digital-comms-emily-creation": soundFileName = "EmilyCreation"; break; default: break; } if (soundFileName == "") { return; } speaking.Speak(soundFileName, handlerName, belongsToSkill); base.Do(intent); }
public static void Act(IntentRecognitionResult intent) { CreditCardApp.AppStatus = AppStatus.New; CreditCardApp.NextStep = AppStep.AgreeCreditCheck; Utils.PlayOneOf(speeches, "IntentHandlers\\CreditCardApply\\ASBCreditCardStart"); }
public override void Do(IntentRecognitionResult intent) { Memory.Sleep = true; Utils.PlayOneOf(speeches, "IntentHandlers\\Sleep"); base.Do(intent); }
public static void Act(IntentRecognitionResult intent) { CreditCardApp.AppStatus = AppStatus.InProgress; CreditCardApp.AgreeCreditCheck = true; CreditCardApp.NextStep = AppStep.WhatIsCurrentAddress; Utils.PlayOneOf(speeches, "IntentHandlers\\CreditCardApply\\AgreeCreditCheck"); }
public void Handle(IntentRecognitionResult intent) { List <Handler> handlers = new List <Handler>(); skills.ForEach(skill => handlers.AddRange( skill.handlers.Where(handler => handler.CanHandle(intent)) )); handlers?.ForEach(handler => handler.Do(intent)); }
public static void Act(IntentRecognitionResult intent) { if (CreditCardApp.AppStatus == AppStatus.Paused) { Utils.Play("DoYouWantResumeExistingCCApp", thisFolderName); return; } Utils.PlayOneOf(speeches, thisFolderName); }
public static void OnIntentRecognised(IntentRecognitionResult intent) { var json = intent.Properties.GetProperty( PropertyId.LanguageUnderstandingServiceResponse_JsonResult); Console.WriteLine($"RECOGNIZED: Text={intent.Text}"); Console.WriteLine($" Intent Id: {intent.IntentId}."); Console.WriteLine($" Language Understanding JSON: {json}."); }
public static void Act(IntentRecognitionResult intent) { noMatchCount += 1; if (noMatchCount > 3) { Utils.Play("DoYouWantSpeakToHuman", thisFolderName); return; } Utils.PlayOneOf(speeches, thisFolderName); }
public void OnIntentRecognised(IntentRecognitionResult intent) { if (Memory.Sleep == true && intent.IntentId != "wake") { return; } if (IsHighEnoughCcore(intent)) { skills.Handle(intent); } }
public void Zing(IntentRecognitionResult result) { var replies = new string[] { "Everyone is working hard this week, especially me.", "UM is about to be finished, Rommel started on Bento Box this sprint," + "James is making good progress on Instant Issuance, whle Trevor busy" + "attending a ton of meetings Yini and Mike are busy on personal loan and " + "production faults", }; Speak(replies.OneOf()); }
public bool IsHighEnoughScore( IntentRecognitionResult intent, double threshold = 0.75) { var intentModel = Deserialize <IntentResultModel>(intent); if (intentModel.TopScoringIntent != null) { return(intentModel.TopScoringIntent.Score > threshold); } return(false); }
public bool IsHighEnoughCcore(IntentRecognitionResult intent) { var json = intent.Properties.GetProperty( PropertyId.LanguageUnderstandingServiceResponse_JsonResult); var intentJsonModel = JsonConvert.DeserializeObject <IntentJsonModel>(json); if (intentJsonModel.TopScoringIntent != null) { return(intentJsonModel.TopScoringIntent.Score > 0.75); } return(false); }
public void WhoIsRebeka(IntentRecognitionResult result) { var replies = new string[] { "Hi everyone, I am a spokewoman that does comms for my team.", "Hi, I'm Rebeka. I am a Zing bot.", "Hi, I'm Rebeka, I am a bot and that's all I can say. " + "If you want to know more about me, please ask Cards Y.", "Ha ha, I am funny, I am curious, and I am constantly improving!", }; Speak(replies.OneOf()); }
public static void Act(IntentRecognitionResult intent) { if (CreditCardApp.AppStatus != AppStatus.Paused) { Utils.Play("DoYouWantANewApp", thisFoldeName); return; } Utils.Play("ResumingAppNow", thisFoldeName); var intentId = IntentIdLocator.Map[CreditCardApp.NextStep]; //var intentHandler = IntentHandlerLocator.Map[intentId]; //intentHandler(intent); }
public virtual void AskUserToRepeatQuestion(IntentRecognitionResult result) { Console.WriteLine($"{GetType().Name} does not have the skill to" + $"intent: {luis.Deserialize<IntentResultModel>(result)}"); var replies = new string[] { "Sorry, I didn't understand what you mean by that.", "Sorry, could you please say that again?", "Sorry, I didn't quite get what you say. " + "Could you please repeat the question again?", "Sorry, could you please repeat that again?", }; Speak(replies.OneOf()); }
public override void Handle(IntentRecognitionResult result) { if (luis.IsHighEnoughScore(result, 0.8) && skills.TryGetValue(result.IntentId, out Action <IntentRecognitionResult> skill )) { LogSkillExecuteBegins(result); skill(result); return; } if (luis.IsHighEnoughScore(result, 0.6)) { AskUserToRepeatQuestion(result); } }
public IIntentDto[] GetActions(IntentRecognitionResult response, string defaultLocation = null) { var thing = response.ThingParameter; var property = response.PropertyParameter; var room = response.RoomParameter ?? defaultLocation; if (response.RoomParameter == null) { response.RoomParameter = defaultLocation; } if (thing == null && property == null && room == null) { Logger.LogError("Parameters missing"); return(new IIntentDto[0]); } var config = _intentToActionMappingRepository.CurrentConfig; var actions = config.Where(c => c.SupportedIntents.Contains(response.IntentLabel)) //quick-filter by intent .SelectMany(c => WhereResponseIsMatch(c, response)).ToArray(); return(actions); }
public override void Do(IntentRecognitionResult intent) { speaking.Speak(handlerName, belongsToSkill); base.Do(intent); }
private IList <PowerIntentDto> MatchTurnOffActions(CubeConfigDto cubeConfigDto, IntentRecognitionResult intent) { var actions = cubeConfigDto.TurnOffIntentActions; return (actions.Where( a => intent.ThingParameter == a.EntityLabel && OptionalMatch(intent.RoomParameter, a.RoomLabel)).ToArray()); }
public virtual void LogSkillExecuteBegins(IntentRecognitionResult result) => Console.WriteLine($"{GetType().Name} handling intent {result.IntentId}");
public abstract void Handle(IntentRecognitionResult result);
private IEnumerable <IIntentDto> WhereResponseIsMatch(CubeConfigDto cubeConfigDto, IntentRecognitionResult intent) { var result = new List <IIntentDto>(); if (intent.IntentLabel == IntentLabel.Get && cubeConfigDto.SupportedIntents.Contains(IntentLabel.Get)) { var actions = MatchGetActions(cubeConfigDto, intent); if (actions.Any()) { result.AddRange(actions); } } if (intent.IntentLabel == IntentLabel.Set && cubeConfigDto.SupportedIntents.Contains(IntentLabel.Set)) { var actions = MatchSetActions(cubeConfigDto, intent); if (actions.Any()) { result.AddRange(actions); } } if (intent.IntentLabel == IntentLabel.TurnOn && cubeConfigDto.SupportedIntents.Contains(IntentLabel.TurnOn)) { var actions = MatchTurnOnActions(cubeConfigDto, intent); if (actions.Any()) { result.AddRange(actions); } } if (intent.IntentLabel == IntentLabel.TurnOff && cubeConfigDto.SupportedIntents.Contains(IntentLabel.TurnOff)) { var actions = MatchTurnOffActions(cubeConfigDto, intent); if (actions.Any()) { result.AddRange(actions); } } return(result); }
private IList <PropertyRelatedIntentDto> MatchGetActions(CubeConfigDto cubeConfigDto, IntentRecognitionResult intent) { var actions = cubeConfigDto.GetIntentActions; return (actions.Where( a => intent.PropertyParameter == a.PropertyLabel && OptionalMatch(intent.ThingParameter, a.EntityLabel) && OptionalMatch(intent.RoomParameter, a.RoomLabel)).ToArray()); }
private IList <PropertyRelatedIntentDto> MatchSetActions(CubeConfigDto cubeConfigDto, IntentRecognitionResult intent) { var actions = cubeConfigDto.SetIntentActions.Where( a => intent.PropertyParameter == a.PropertyLabel && OptionalMatch(intent.ThingParameter, a.EntityLabel) && OptionalMatch(intent.RoomParameter, a.RoomLabel)).ToArray(); if (intent.NumericParameter != null) { foreach (var action in actions) { action.NumericParameter = intent.NumericParameter.Value; } } return(actions); }
public static void OnSpeechRecognised(IntentRecognitionResult result) { Console.WriteLine($"RECOGNIZED: Text={result.Text}"); Console.WriteLine($" Intent not recognized."); }
public virtual bool CanHandle(IntentRecognitionResult intent) { return(intentsToHandle.Contains(intent.IntentId)); }
public virtual void Do(IntentRecognitionResult intent) { // TODO: maybe generic clean up tasks here? return; }
public static void Act(IntentRecognitionResult intent) { CreditCardApp.AppStatus = AppStatus.Paused; Utils.PlayOneOf(speeches, "IntentHandlers\\CreditCardApply\\CreditCardApplySleep"); }