Skip to main content

Chinese to time, time to Chinese.

Project description

📦 nlp-time

Time NLP module

Installation

pip install -i https://mirrors.aliyun.com/pypi/simple/ --extra-index-url https://pypi.org/simple/ nlp-time

Example

import nlp_time
from datetime import datetime
# Partial replacement according to regular expression
res = nlp_time.get_time("我是周六早上6点的飞机")
# output: ('周六早上6点', ('2022-05-28 06:00:00', '2022-05-28 06:59:59'))
res = nlp_time.get_time("我是周六早上6点的飞机", tend_future=False)
# output: ('周六早上6点', ('2022-05-21 06:00:00', '2022-05-21 06:59:59'))
res = nlp_time.get_text(datetime.strptime("2022-05-22 20:06:00", "%Y-%m-%d %H:%M:%S"))
# output: 昨天晚上20点06分
res = nlp_time.get_text("2022-05-22 20:06:00")
# output: 昨天晚上20点06分
res = nlp_time.get_text("2021-05-22 20:06:00")
# output: 去年5月22号晚上20点06分
res = nlp_time.get_text(1653091200)
# output: 前天早上8点
res = nlp_time.get_text("2021-05-18 20:06:00")
# output: 上周三晚上20点06分

To Do

  • Be the best version of you.

More Resources

License

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

Project details


Download files

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

Source Distribution

nlp-time-0.1.14.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

nlp_time-0.1.14-py3-none-any.whl (5.9 kB view hashes)

Uploaded Python 3

Supported by

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