mindmeld.ser module

This module contains the system entity recognizer.

mindmeld.ser.get_candidates(query, entity_types=None, locale=None, language=None, time_zone=None, timestamp=None)[source]

Identifies candidate system entities in the given query.

Parameters:
  • query (Query) -- The query to examine
  • entity_types (list of str) -- The entity types to consider
  • locale (str, optional) -- The locale representing the ISO 639-1 language code and ISO3166 alpha 2 country code separated by an underscore character.
  • language (str, optional) -- Language as specified using a 639-1/2 code.
  • time_zone (str, optional) -- An IANA time zone id such as 'America/Los_Angeles'. If not specified, the system time zone is used.
  • timestamp (long, optional) -- A unix timestamp used as the reference time. If not specified, the current system time is used. If time_zone is not also specified, this parameter is ignored.
Returns:

The system entities found in the query

Return type:

list of QueryEntity

mindmeld.ser.get_candidates_for_text(text, entity_types=None, language=None, locale=None)[source]

Identifies candidate system entities in the given text.

Parameters:
  • text (str) -- The text to examine
  • entity_types (list of str) -- The entity types to consider
  • language (str) -- Language code
  • locale (str) -- Locale code
Returns:

The system entities found in the text

Return type:

list of dict

mindmeld.ser.parse_numerics(sentence, dimensions=None, language=None, locale=None, time_zone=None, timestamp=None)[source]

Calls System Entity Recognizer service API to extract numerical entities from a sentence.

Parameters:
  • sentence (str) -- A raw sentence.
  • dimensions (None or list of str) -- The list of types (e.g. volume, temperature) to restrict the output to. If None, include all types.
  • language (str, optional) -- Language of the sentence specified using a 639-1/2 code. If both locale and language are provided, the locale is used. If neither are provided, the EN language code is used.
  • locale (str, optional) -- The locale representing the ISO 639-1 language code and ISO3166 alpha 2 country code separated by an underscore character.
  • time_zone (str, optional) -- An IANA time zone id such as 'America/Los_Angeles'. If not specified, the system time zone is used.
  • timestamp (long, optional) -- A unix millisecond timestamp used as the reference time. If not specified, the current system time is used. If time_zone is not also specified, this parameter is ignored.
Returns:

A tuple containing:
  • response (list, dict): Response from the System Entity Recognizer service that consists of a list of dicts, each corresponding to a single prediction or just a dict, corresponding to a single prediction.
  • response_code (int): http status code.

Return type:

(tuple)

mindmeld.ser.resolve_system_entity(query, entity_type, span)[source]

Resolves a system entity in the provided query at the specified span.

Parameters:
  • query (Query) -- The query containing the entity
  • entity_type (str) -- The type of the entity
  • span (Span) -- The character span of the entity in the query
Returns:

The resolved entity

Return type:

Entity

Raises:

SystemEntityResolutionError