dateparser.languages package¶
Submodules¶
dateparser.languages.detection module¶
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 or unicode tokens.
- Returns:
True if tokens are valid, False otherwise.
- split(string, keep_formatting=False)[source]¶
Split the date string using translations in locale info.
- Parameters:
string (str|unicode) – Date string to be splitted.
keep_formatting (bool) – If True, retain formatting of the date string.
- Returns:
A list of string tokens formed after splitting the date string.
- class dateparser.languages.dictionary.NormalizedDictionary(locale_info, settings=None)[source]¶
Bases:
Dictionary
dateparser.languages.language module¶
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|unicode) – 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|unicode) – 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|unicode) – 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.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¶