Skip to main content

A parser for fuzzy dates

Project description

Python Parser for Abbreviated Dates

PypI - Version issues stars - stars stars - stars contributions - contributions

Key FeaturesHow To UseHow it worksCommon use casesOperationsRoadmap

Have you ever tried to understand a date like 11-09, št? Is the št an abbreviation of a month or a weekday? Which of those numbers represent the month or the day? This library leverages on Good Ol' Fashioned AI to parse abbreviated, ambiguous, and incomplete dates in multiple languages.

Key Features

  • Language auto-detection
  • Easily expandable into new languages (30 languages are currently supported)
  • Support for multiple date formats
  • Support for abbreviated weekdays
  • Support for abbreviated months
  • Support for ambiguous month/day numbers

How To Use

The most straightforward way to parse dates is to use the datetime.date() function, that wraps around most of the functionality of the module. This example shows a basic usage of the library to parse the date: "11-09, št":

fuzzy_parser '11-09, št'
[datetime.date(2024, 11, 9)]
['%m %d %a']

How it works

The abbreviation "št" could stand for:

  • Šeštadienis which means in Saturday in Lithuanian
  • Štvrtok which means in Thursday in Slovak

Lithuanian is spoken in Lithuania and in Latvia. Slovak is spoken in Slovakia but also by a minority in the Czech Republic. These countries use different date representations: Czech Republic, Latvia and Slovakia have the day written first because of the "little" date endianness format used as the standard in the country. Lithuania, on the other hand, uses the "big" date endianness format which means that the month is written first. The system factor in all these facts and is able to come with the right answers:

In the case of interpreting the abbreviation as a Saturday:

  • 9 of November 2024
  • 11 of September 2027

In the case of interpreting the abbreviation as a Thursday:

  • 11 of September 2025

For further details have a look at the underlying implementation. In addition, the unit tests might give an impression on how to use this library.

Common use cases

Consuming data from different sources:

  • Scraping: extract dates from different places with several formats and languages
  • IoT: consuming data coming from different sources with different date formats
  • Tooling: consuming dates from different logs / sources
  • Format transformations: when transforming dates coming from different files (PDF, CSV, etc.) to other formats (database, etc).

Operations

We are leveraging GNU Make to automate frequent actions. Please use the following command will show the available recipes to use for operating the local development environment:

make help
Click to see the available recipes
Command Description
help Print this help
synchronize Switch to the main branch, fetch changes & delete merged branches
install Install the latest library release
requirements Install the packages packs required for the development environment
release Release recipe to be use from Github Actions
test Run the test suite
bump Increase the version number
publish Publish the diagrams
workflow Creates the Diagrams
clean Remove debris
remove-all Remove packages and packs

Compatibility

Tested with SWI-Prolog version 8.2.4 on Ubuntu 20.04

License

Distributed under the MIT License. See LICENSE file for more information.

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

fuzzy_parser-0.2.41.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

fuzzy_parser-0.2.41-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file fuzzy_parser-0.2.41.tar.gz.

File metadata

  • Download URL: fuzzy_parser-0.2.41.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.0 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9

File hashes

Hashes for fuzzy_parser-0.2.41.tar.gz
Algorithm Hash digest
SHA256 8228ec4882893cbe55c0e35adbd12b6364ca1a5a948d29453f36b8da9861bb9b
MD5 d8ea97424af4ee2d0e373bc2a9a5f448
BLAKE2b-256 f2302ce160b1c9fab4a75a1cb188f6bd46d92221f60e3827d9f9f79618174d08

See more details on using hashes here.

File details

Details for the file fuzzy_parser-0.2.41-py3-none-any.whl.

File metadata

  • Download URL: fuzzy_parser-0.2.41-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.0 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9

File hashes

Hashes for fuzzy_parser-0.2.41-py3-none-any.whl
Algorithm Hash digest
SHA256 07ae73f6dd5ff0e21fa76e556985820ebd01395c689212fd380f7d85a7980759
MD5 ced869327d5a1cfc86e1882a10bfcfaa
BLAKE2b-256 f1722df78f0cb6f8e8a251d26fbf245403949642a9201b1584dbda6850969efa

See more details on using hashes here.

Supported by

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