Skip to content

Instantly share code, notes, and snippets.

@AndyButland
Created January 20, 2019 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndyButland/ded060141a45998375e985555a58cee5 to your computer and use it in GitHub Desktop.
Save AndyButland/ded060141a45998375e985555a58cee5 to your computer and use it in GitHub Desktop.
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