Created
January 20, 2019 10:43
-
-
Save AndyButland/ded060141a45998375e985555a58cee5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class BaseHandlePersonIntentStrategy : BaseHandleIntentStrategy | |
{ | |
protected BaseHandlePersonIntentStrategy(IPersonService personService) | |
{ | |
PersonService = personService; | |
} | |
public IPersonService PersonService { get; } | |
protected static string GetPersonEntityValue(IDictionary<string, object> entities) | |
{ | |
return GetStringEntityValue(entities, LuisSettings.Person.Entities.Person); | |
} | |
protected static string GetProvidedOrRecalledEntityPersonName(ConversationData conversationData, string entityName) | |
{ | |
if (string.IsNullOrEmpty(entityName) || IsThirdPersonPronounRequested(entityName)) | |
{ | |
return conversationData.LastRecognisedEntityPerson; | |
} | |
return entityName; | |
} | |
private static bool IsThirdPersonPronounRequested(string entityName) | |
{ | |
var entityNameParts = entityName.Trim().ToLowerInvariant().Split(' '); | |
var lastEntityRequests = new[] { "he", "she", "his", "her", "him" }; | |
return entityNameParts.Any(x => lastEntityRequests.Contains(x)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment