Skip to main content

Hungarian Date Parser

A tool for extracting datetime intervals from Hungarian sentences and turning datetime objects into Hungarian text.

Stars Badge Issues Badge License Badge Tests

Install and try the package with pip install hun-date-parser.

:fire: Usage

If not specified otherwise, relative dates (eg.: tomorrow, next week, etc.) are calculated relative to the current datetime, at the time when the DatetimeExtractor is instanciated.

from hun_date_parser import DatetimeExtractor

datetime_extractor = DatetimeExtractor()

datetime_extractor.parse_datetime('találkozzunk jövő kedd délután!')
# {'start_date': datetime.datetime(2020, 12, 29, 12, 0), 'end_date': datetime.datetime(2020, 12, 29, 17, 59, 59)}

datetime_extractor.parse_datetime('találkozzunk szombaton háromnegyed nyolc előtt két perccel')
# {'start_date': datetime.datetime(2020, 12, 26, 7, 43), 'end_date': datetime.datetime(2020, 12, 26, 7, 43, 59)}

The date parser is also capable of parsing explicit intervals from the text even when only one side of the interval is specified.

datetime_extractor.parse_datetime('2020 decemberétől 2021 januárig')
# {'start_date': datetime.datetime(2020, 12, 1, 0, 0), 'end_date': datetime.datetime(2021, 1, 31, 23, 59, 59)}


datetime_extractor.parse_datetime('2020 decemberéig')
# {'start_date': None, 'end_date': datetime.datetime(2020, 12, 31, 23, 59, 59)}

The library is also capable of turning datetime objects into their Hungarian text representation.

from datetime import datetime
from hun_date_parser import DatetimeTextualizer

datetime_textualizer = DatetimeTextualizer()

datetime_textualizer.generate_candidates()

datetime_textualizer.generate_candidates(datetime(2020, 12, 20, 18, 34), time_precision=2)
# {'date': ['ezen a héten vasárnap', '2020 december 20'],
#  'times': ['tizennyolc óra harmincnégy perc', '18:34', 'este hat óra harmincnégy perc', 'este fél 7 után 4 perccel']}

:pencil: License

This project is licensed under Apache-2.0 license. Feel free to use it in your own projects.

:wrench: Contribute

Any help or feedback in further developing the library is welcome!

Metadata

Release files for hun-date-parser-nsoma97 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hun-date-parser-nsoma97 0.0.1
File Size Uploaded
hun-date-parser-nsoma97-0.0.1.tar.gz 12.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hun-date-parser-nsoma97 0.0.1
File Interpreter ABI Platform
hun_date_parser_nsoma97-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.2 kB

Release files / hun-date-parser-nsoma97-0.0.1.tar.gz

Download URL hun-date-parser-nsoma97-0.0.1.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fb4157254d49393113b8e21ae93b80799f8602e6097f7037d6875d615b47f766
BLAKE2b-256 checksum
How to use checksums
0cecfe633b292a6f0de92dac57c9988d4062105b2e336fd55595a22a823e3972
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release files / hun_date_parser_nsoma97-0.0.1-py3-none-any.whl

Download URL hun_date_parser_nsoma97-0.0.1-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d78fb6c2a212251a43aa9bc6e8b1ed57f404fcf35c57ccd0859d6357b17aa709
BLAKE2b-256 checksum
How to use checksums
74694f2fdc1af3025dcdc9835e8f1bd42962751b265a226fa2811f4857787b9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page