-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from nsoma97/add_readme
Add readme
- Loading branch information
Showing
22 changed files
with
120 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,66 @@ | ||
# hun-date-parser | ||
<h1 align="center">Hungarian Date Parser</h1> | ||
|
||
<p align="center"> | ||
<i>A tool for extracting datetime intervals from Hungarian sentences and turning datetime objects into Hungarian text.</i> | ||
</p> | ||
|
||
|
||
<div align="center"> | ||
<img src="https://img.shields.io/github/stars/nsoma97/hun-date-parser" alt="Stars Badge"/> | ||
<img src="https://img.shields.io/github/issues/nsoma97/hun-date-parser" alt="Issues Badge"/> | ||
<img src="https://img.shields.io/github/license/nsoma97/hun-date-parser?color=2b9348" alt="License Badge"/> | ||
<img src="https://img.shields.io/github/workflow/status/nsoma97/hun-date-parser/Datetime Parser Pipeline" alt="Tests"/> | ||
</div> | ||
|
||
<br> | ||
|
||
|
||
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. | ||
|
||
```python | ||
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. | ||
```python | ||
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. | ||
|
||
```python | ||
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](https://www.apache.org/licenses/LICENSE-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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from hun_date_parser.date_textualizer.datetime_textualizer import DatetimeTextualizer | ||
from hun_date_parser.date_parser.datetime_extractor import DatetimeExtractor | ||
|
||
__all__ = ["DatetimeTextualizer", "DatetimeExtractor"] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions
5
src/date_textualizer/datetime_textualizer.py → .../date_textualizer/datetime_textualizer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/date_textualizer/time2text.py → ...date_parser/date_textualizer/time2text.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import setuptools | ||
|
||
with open("README.md", "r", encoding="utf-8") as fh: | ||
long_description = fh.read() | ||
|
||
setuptools.setup( | ||
name="hun-date-parser", | ||
version="0.0.1", | ||
author="Soma Nagy", | ||
author_email="nagysomabalint@gmail.com", | ||
description="A tool for extracting datetime intervals from Hungarian sentences and turning datetime objects into Hungarian text.", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/nsoma97/hun-date-parser", | ||
packages=setuptools.find_packages(), | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Operating System :: OS Independent", | ||
], | ||
python_requires='>=3.6', | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters