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 <PowerIntentDto> MatchTurnOffActions(CubeConfigDto cubeConfigDto, IntentRecognitionResult intent) { var actions = cubeConfigDto.TurnOffIntentActions; return (actions.Where( a => 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); }
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); }