dateparser.languages package
Submodules
dateparser.languages.dictionary module
- class dateparser.languages.dictionary.Dictionary(locale_info, settings=None)[source]
Bases:
object
Class that modifies and stores translations and handles splitting of date string.
- Parameters:
locale_info – Locale info (translation data) of the locale.
settings (dict) – Configure customized behavior using settings defined in
dateparser.conf.Settings
.
- Returns:
a Dictionary instance.
- are_tokens_valid(tokens)[source]
Check if tokens are valid tokens for the locale.
- Parameters:
tokens (list) – a list of string tokens.
- Returns:
True if tokens are valid, False otherwise.
- class dateparser.languages.dictionary.NormalizedDictionary(locale_info, settings=None)[source]
Bases:
Dictionary
dateparser.languages.loader module
- class dateparser.languages.loader.LocaleDataLoader[source]
Bases:
object
Class that handles loading of locale instances.
- get_locale(shortname)[source]
Get a locale instance.
- Parameters:
shortname (str) – A locale code, e.g. ‘fr-PF’, ‘qu-EC’, ‘af-NA’.
- Returns:
locale instance
- get_locale_map(languages=None, locales=None, region=None, use_given_order=False, allow_conflicting_locales=False)[source]
Get an ordered mapping with locale codes as keys and corresponding locale instances as values.
- Parameters:
languages (list) – A list of language codes, e.g. [‘en’, ‘es’, ‘zh-Hant’]. If locales are not given, languages and region are used to construct locales to load.
locales (list) – A list of codes of locales which are to be loaded, e.g. [‘fr-PF’, ‘qu-EC’, ‘af-NA’]
region (str) – A region code, e.g. ‘IN’, ‘001’, ‘NE’. If locales are not given, languages and region are used to construct locales to load.
use_given_order (bool) – If True, the returned mapping is ordered in the order locales are given.
allow_conflicting_locales (bool) – if True, locales with same language and different region can be loaded.
- Returns:
ordered locale code to locale instance mapping
- get_locales(languages=None, locales=None, region=None, use_given_order=False, allow_conflicting_locales=False)[source]
Yield locale instances.
- Parameters:
languages (list) – A list of language codes, e.g. [‘en’, ‘es’, ‘zh-Hant’]. If locales are not given, languages and region are used to construct locales to load.
locales (list) – A list of codes of locales which are to be loaded, e.g. [‘fr-PF’, ‘qu-EC’, ‘af-NA’]
region (str) – A region code, e.g. ‘IN’, ‘001’, ‘NE’. If locales are not given, languages and region are used to construct locales to load.
use_given_order (bool) – If True, the returned mapping is ordered in the order locales are given.
allow_conflicting_locales (bool) – if True, locales with same language and different region can be loaded.
- Yield:
locale instances
dateparser.languages.locale module
- class dateparser.languages.locale.Locale(shortname, language_info)[source]
Bases:
object
Class that deals with applicability and translation from a locale.
- Parameters:
- Returns:
A Locale instance
- is_applicable(date_string, strip_timezone=False, settings=None)[source]
Check if the locale is applicable to translate date string.
dateparser.languages.validation module
- class dateparser.languages.validation.LanguageValidator[source]
Bases:
object
- VALID_KEYS = ['name', 'skip', 'pertain', 'simplifications', 'no_word_spacing', 'ago', 'in', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december', 'year', 'month', 'week', 'day', 'hour', 'minute', 'second', 'sentence_splitter_group']
- logger = None