Skip to main content

Разбор дат в строке. Порт на python проекта https://github.com/DenisNP/Hors

Project description

Hors

MIT License

hors - это модуль python для распознавания даты и времени в естественной речи на русском языке. Умеет понимать сложные конструкции с абсолютными и относительными датой и временем. В том числе временные периоды. Хорс — это славянский бог солнца

Оригинальная версия библиотеки написана Денисом Пешехоновым на C# и доступна на github под лицензией MIT. Изменения логики минимальны

Установка

pip install hors

Использование

>>> import hors
>>> r = hors.process_phrase('Утром 3 сентября 2059 года мы слушали Шуфутинского')
>>> r.dates[0].type
<DateTimeTokenType.FIXED: 1>
>>> r.dates[0].date_from
datetime.datetime(2059, 9, 3, 9, 0)
>>> r = hors.process_phrase('Полёт Гагарина длился с 9 утра 12 апреля 1961 года до 11 утра')
>>> r.dates[0].type
<DateTimeTokenType.PERIOD: 2>
>>> r.dates[0].date_from
datetime.datetime(1961, 4, 12, 9, 0)
>>> r.dates[0].date_to  
datetime.datetime(1961, 4, 12, 11, 0)

Тестирование

python -m unittest discover tests

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hors-0.1.6.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hors-0.1.6-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file hors-0.1.6.tar.gz.

File metadata

  • Download URL: hors-0.1.6.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for hors-0.1.6.tar.gz
Algorithm Hash digest
SHA256 08df913234e1faae600b42a99d95c5d2bb6116384bbe22a7df6f303afce24992
MD5 7f6e76771725ae5cafb408f0261b14e5
BLAKE2b-256 b7f4deff61e48b094c875dca114116352e2092c01fb4ccc5e457cd74e72a9fcc

See more details on using hashes here.

File details

Details for the file hors-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: hors-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for hors-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0abed3413c5273751c266078feb8b29cdbe4d3f61fbd06751143615372e59f2c
MD5 417b632558dc7a87bbaf45d3ffd06269
BLAKE2b-256 01c07da4dd6992885d82b0508296bd86d23b353e57d4eeb1718905fbdf647a25

See more details on using hashes here.

Supported by

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