Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EntityRecognizer

Utility class used to parse & resolve common entities like datetimes received from LUIS.

Hierarchy

  • EntityRecognizer

Index

Methods

Static expandChoices

  • expandChoices(choices: string | Object | string[]): string[]
  • Converts a set of choices into an expanded array.

    Parameters

    • choices: string | Object | string[]
      • choices: {string} - Pipe ('|') delimited list of values.
      • choices: {Object} - Object used to generate the list of choices. The objects field names will be used to build the list of choices.
      • choices: {string[]} - Array of strings. This will just be echoed back as the output.

    Returns string[]

Static findAllEntities

  • Finds all occurrences of a specific entity type within a set.

    Parameters

    • entities: IEntity[]

      Set of entities to search over.

    • type: string

      Type of entity to find.

    Returns IEntity[]

Static findAllMatches

  • findAllMatches(choices: string | Object | string[], utterance: string, threshold?: number): IFindMatchResult[]
  • Finds all possible matches for a users utterance given a list of choices.

    Parameters

    • choices: string | Object | string[]
      • choices: {string} - Pipe ('|') delimited list of values to compare against the users utterance.
      • choices: {Object} - Object used to generate the list of choices. The objects field names will be used to build the list of choices.
      • choices: {string[]} - Array of strings to compare against the users utterance.
    • utterance: string

      Text utterance to parse.

    • Optional threshold: number

      (Optional) minimum score needed for a match to be considered. The default value is 0.6.

    Returns IFindMatchResult[]

Static findBestMatch

  • findBestMatch(choices: string | Object | string[], utterance: string, threshold?: number): IFindMatchResult
  • Finds the best match for a users utterance given a list of choices.

    Parameters

    • choices: string | Object | string[]
      • choices: {string} - Pipe ('|') delimited list of values to compare against the users utterance.
      • choices: {Object} - Object used to generate the list of choices. The objects field names will be used to build the list of choices.
      • choices: {string[]} - Array of strings to compare against the users utterance.
    • utterance: string

      Text utterance to parse.

    • Optional threshold: number

      (Optional) minimum score needed for a match to be considered. The default value is 0.6.

    Returns IFindMatchResult

Static findEntity

  • Searches for the first occurance of a specific entity type within a set.

    Parameters

    • entities: IEntity[]

      Set of entities to search over.

    • type: string

      Type of entity to find.

    Returns IEntity

Static parseBoolean

  • parseBoolean(value: string): boolean
  • Parses a boolean from a users utterance.

    Parameters

    • value: string

      Text utterance to parse.

    Returns boolean

    A valid boolean otherwise undefined.

Static parseNumber

  • parseNumber(value: string | IEntity[]): number
  • Parses a number from either a users text utterance or a set of entities.

    Parameters

    • value: string | IEntity[]
      • value: {string} - Text utterance to parse.
      • value: {IEntity[]} - Set of entities to resolve.

    Returns number

    A valid number otherwise Number.NaN.

Static parseTime

  • parseTime(value: string | IEntity[]): Date
  • Parses a date from either a users text utterance or a set of entities.

    Parameters

    • value: string | IEntity[]
      • value: {string} - Text utterance to parse. The utterance is parsed using the Chrono library.
      • value: {IEntity[]} - Set of entities to resolve.

    Returns Date

    A valid Date object if the user spoke a time otherwise null.

Static recognizeTime

  • recognizeTime(utterance: string, refDate?: Date): IEntity
  • Recognizes a time from a users utterance. The utterance is parsed using the Chrono library.

    Parameters

    • utterance: string

      Text utterance to parse.

    • Optional refDate: Date

      (Optional) reference date used to calculate the final date.

    Returns IEntity

    An entity containing the resolved date if successful or null if a date couldn't be determined.

Static resolveTime

  • resolveTime(entities: IEntity[]): Date
  • Calculates a Date from a set of datetime entities.

    Parameters

    • entities: IEntity[]

      List of entities to extract date from.

    Returns Date

    The successfully calculated Date or null if a date couldn't be determined.

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method