Skip to main content

Time convert for Chinese text

Project description

Time Convert

Introduction

中文语义时间提取转换

Install

pip install time-convert

Usage

eg1:

from time_convert import TimeNormalizer

tc = TimeNormalizer()

msg = 明天去你家'

res = tc.parse(msg)

print``(res)

{'key': '明天', 'type': 'timestamp', 'date': '2019-09-26 00:00:00'}

eg2:

from time_convert import TimeNormalizer

tc = TimeNormalizer()

msg = 明天去你家'

timeBase=2013-02-28 16:30:29`

res = tc.parse(msg, timeBase)

print``(res)

{'key': '明天', 'type': 'timestamp', 'date': '2013-03-01 00:00:00'}

返回值类型说明

Time_Convert总的会返回四种类型的情况:

  • 1、timespan
  • 2、timestamp
  • 3、timedelta
  • 4、error

Mark

  • 1、时间解析的默认basetime时间为请求的当前时间。
  • 2、也可以指定basetime,basetime的格式为:YYYY-MM-DD 00:00:00

To do list

  • 1、timedelta的拼接
  • 2、'一会儿'等口语化表述时间的提取
  • 3、过两天,明天吧
  • 4、下礼拜

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

time_convert-1.2.5-py3-none-any.whl (43.2 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