This repository has been archived by the owner on Mar 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
88 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
__pycache__ | ||
help | ||
rutimeparser.egg-info | ||
*.egg-info | ||
dist/ | ||
|
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,80 @@ | ||
RuTimeParser | ||
============ | ||
|
||
Данный модуль содержит базовый класс и упрощающие работу с ним функции | ||
для извлечения даты и времени из текста на русском языке. | ||
|
||
Установка | ||
--------- | ||
|
||
``sudo pip3 install rutimeparser`` | ||
|
||
Использование | ||
------------- | ||
|
||
Примеры ниже приведены для 2 апреля 2017 года. | ||
|
||
Извлечение даты и времени: | ||
|
||
.. code:: python | ||
>>> from rutimeparser import parse | ||
>>> parse('завтра') | ||
datetime.date(2017, 4, 3) | ||
>>> parse('завтра утром') | ||
datetime.datetime(2017, 4, 3, 9, 0) | ||
>>> parse('Напомни мне завтра утром составить список дел.') | ||
datetime.datetime(2017, 4, 3, 9, 0) | ||
Извлечение текста, не относящегося к дате и времени: | ||
|
||
.. code:: python | ||
>>> from rutimeparser import get_clear_text, get_last_clear_text | ||
>>> get_clear_text('Напомни мне завтра утром составить список дел.') | ||
'напомни мне составить список дел' | ||
>>> get_last_clear_text('Напомни мне завтра утром составить список дел.') | ||
'составить список дел' | ||
Неявные ситуации | ||
---------------- | ||
|
||
- ``утром`` - в 09:00 | ||
- ``днём`` - в 15:00 | ||
- ``вечером`` - в 21:00 | ||
- ``ночью`` - в 03:00 | ||
- ``на следующей неделе`` - на следующей неделе в понедельник. | ||
- ``через неделю`` - ровно через 7 суток. | ||
- ``через неделю утром`` - через 7 дней утром. | ||
- ``в следующем месяце`` - 1 число следующего месяца. | ||
|
||
Больше примеров в `tests.py <tests.py>`__ | ||
|
||
API reference | ||
------------- | ||
|
||
Параметры ``rutimeparser.parse``: | ||
|
||
- ``words`` (str, list, tuple) -- Строка с текстом или список слов. | ||
Параметр является необязательным, т.к. может быть передан | ||
непосредственно в метод ``parse``. | ||
- ``tz`` (str) -- Название часового пояса. Если не указано, | ||
возвращается наивное время. | ||
- ``now`` (datetime.datetime) -- От какого момента считать текущее | ||
время | ||
- ``allowed_results`` (list, tuple) -- Список объектов, которые могут | ||
быть возвращены методом ``parse``. Возможные значения -- datetime, | ||
date, time, None. | ||
- ``default_time`` (datetime.time) -- Время по умолчанию. Используется | ||
только в том случае, если из текста удалось получить только date, но | ||
необходимо вернуть datetime. По умолчанию 09:00. | ||
- ``default_datetime`` (datetime.datetime) -- Дата и время по | ||
умолчанию. Возвращается методом ``parse``, если в тексте не удалось | ||
найти значение, подходящее под ``allowed_results``. По умолчанию | ||
равен значению параметра ``now``. | ||
|
||
TODO | ||
---- | ||
|
||
- Перейти на ``pymorphy`` | ||
- Добавить поддержку AM/PM (например, "в два часа дня") |
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,3 @@ | ||
pandoc --from=markdown --to=rst --output=README.rst README.md | ||
python3 setup.py sdist | ||
twine upload dist/* |
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 |
---|---|---|
|
@@ -5,11 +5,11 @@ | |
|
||
setup( | ||
name='rutimeparser', | ||
version='1.0.0', | ||
version='1.1.0', | ||
author='orsinium', | ||
author_email='[email protected]', | ||
description='Recognize date and time in russian text.', | ||
long_description=open('README.md').read(), | ||
long_description=open('README.rst').read(), | ||
keywords='timeparser parse date time datetime russian text', | ||
packages=['rutimeparser'], | ||
requires=['python (>= 3.4)'], | ||
|