mindmeld.query_factory module

This module contains the query factory class.

class mindmeld.query_factory.QueryFactory(text_preparation_pipeline=None, locale=None, language=None, system_entity_recognizer=None, duckling=False)[source]

Bases: object

An object which encapsulates the components required to create a Query object.

text_preparation_pipeline

TextPreparationPipeline -- Pipeline class responsible for processing queries.

language

str -- the language of the text

locale

str -- the locale of the text

system_entity_recognizer

SystemEntityRecognizer -- default to NoOpSystemEntityRecognizer

duckling

bool -- if no system entity recognizer is provided, initialize a new Duckling recognizer instance.

create_query(text, time_zone=None, timestamp=None, locale=None, language=None)[source]

Creates a query with the given text.

Parameters:
  • text (str) -- Text to create a query object for
  • time_zone (str, optional) -- An IANA time zone id to create the query relative to.
  • timestamp (int, optional) -- A reference unix timestamp to create the query relative to, in seconds.
  • 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
Returns:

A newly constructed query

Return type:

Query

static create_query_factory(app_path, text_preparation_pipeline=None, system_entity_recognizer=None, duckling=False)[source]

Creates a query factory for the application.

Parameters:
  • app_path (str, optional) -- The path to the directory containing the app's data. If None is passed, a default query factory will be returned.
  • text_preparation_pipeline (TextPreparationPipeline, optional) -- Pipeline class responsible for processing queries.
  • system_entity_recognizer (SystemEntityRecognizer) -- If not passed, we use either the one from the application's configuration or NoOpSystemEntityRecognizer.
  • duckling (bool, optional) -- if no system entity recognizer is provided, initialize a new Duckling recognizer instance.
Returns:

A QueryFactory object that is used to create Query objects.

Return type:

QueryFactory

normalize(text)[source]

Normalizes the given text.

Parameters:text (str) -- Text to process
Returns:Normalized text
Return type:str