Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nadar-0.1.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

nadar-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file nadar-0.1.0.tar.gz.

File metadata

  • Download URL: nadar-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for nadar-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0e9c8f83f7812e6b9c18ef18093197de546e2a3058aa88aec7130b7a6c4c11db
MD5 a31357d4ff8c3fd5e1e8835e77104ff0
BLAKE2b-256 24cb8a347107e89d07c69bbf92396f71f61267e5e20e028e9bef96c55ac728b8

See more details on using hashes here.

File details

Details for the file nadar-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nadar-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for nadar-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5847bc789c98ea3bcd29dcac0e4f4c57545e1ebce505540c500a45b459c276fa
MD5 ee35ec8f52ba646a227e1803bf78bd1d
BLAKE2b-256 a67027dd2cc9f0b4114bba9d4821cb34b65bdb002ecc6a4742b4feb12d85fe9b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page