NAtural DAte Ranges - automatic translation of natural language phrases describing date ranges into relevant dates or strings
Project description
NAtural DAte Ranges
The purposed of this package is to translate natural language phrases describing date ranges into relevant dates or strings.
Installation
pip install nadar
How to use the package
import nadar as nd
parse_reference
Takes in a string representing a delta in date and returns it given the reference date.
>>> nd.parse_reference('today')
SmartDate(2020-05-18)
>>> parse_reference('hace tres meses')
SmartDate(2018, 2, 8)
parse_period
Takes in a string representing a period and returns it given the reference date.
>>> nd.parse_period('last month')
SmartPeriod(SmartDate(2018, 4, 1), SmartDate(2018, 4, 30))
>>> nd.parse_period('last year', reference='2017-10-28')
SmartPeriod(SmartDate(2016, 1, 1), SmartDate(2016, 12, 31))
smart_dates
Wrapper for both parse_period() and parse_reference() returning a tuple of strings.
>>> nd.smart_dates('4 months ago')
('2020-01-01', '2020-01-31')
>>> nd.smart_dates('yesterday')
('2020-05-19', '2020-05-19')
Acknowledgment
The main author of the code for this package is Benjamin Wolter, PhD.
The author of the original idea for the functionality is Sergey Ivanov, PhD
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.