A tool for extracting datetime intervals from Hungarian sentences and turning datetime objects into Hungarian text.
Project description
Hungarian Date Parser
A tool for extracting datetime intervals from Hungarian sentences and turning datetime objects into Hungarian text.
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!
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.
Source Distribution
Built Distribution
File details
Details for the file hun-date-parser-nsoma97-0.0.1.tar.gz
.
File metadata
- Download URL: hun-date-parser-nsoma97-0.0.1.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb4157254d49393113b8e21ae93b80799f8602e6097f7037d6875d615b47f766 |
|
MD5 | 10bfd3c2ae2aec459a6763e851d8c66e |
|
BLAKE2b-256 | 0cecfe633b292a6f0de92dac57c9988d4062105b2e336fd55595a22a823e3972 |
File details
Details for the file hun_date_parser_nsoma97-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: hun_date_parser_nsoma97-0.0.1-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d78fb6c2a212251a43aa9bc6e8b1ed57f404fcf35c57ccd0859d6357b17aa709 |
|
MD5 | a43fa19b3335df8c62c8f7cd31b1ad9d |
|
BLAKE2b-256 | 74694f2fdc1af3025dcdc9835e8f1bd42962751b265a226fa2811f4857787b9a |