Skip to main content

This is a tool for converting chinese time phrases into time spans.

Project description

CNSeq2TimeSpan

此项目基于zhanzecheng的Time_NLP,并增添了时间域的输出。

Install

pip install CNSeq2TimeSpan

Examples

from CNSeq2TimeSpan.TimeNormalizer import TimeNormalizer
tn = TimeNormalizer()

res = tn.parse(target=u'今年的财务报表交了吗')
print(res)

res = tn.parse(target=u'昨天刚写完,明天早上就交')
print(res)

返回结果

{
	'timebase': '2019-11-21-15-3-58',
	'word': ['今年'],
	'type': 'timespan',
	'timespan': [
		['2019-01-01 00:00:00', '2019-12-31 23:59:59']
	]
}

{
	'timebase': '2019-11-21-8-3-58',
	'word': ['昨天', '明天早上'],
	'type': 'timespan',
	'timespan': [
		['2019-11-20 00:00:00', '2019-11-20 23:59:59'],
		['2019-11-21 06:00:00', '2019-11-21 09:00:00']
	]
}

简介

Time-NLP的python3版本
python 版本https://github.com/sunfiyes/Time-NLPY
Java 版本https://github.com/shinyke/Time-NLP

使用方式

demo:python3 Test.py

优化说明

问题 以前版本 现在版本
无法解析下下周末 "timestamp": "2018-04-01 00:00:00" "timestamp": "2018-04-08 00:00:00"
无法解析 3月4 "2018-03-01" "2018-03-04"
无法解析 初一 初二 cannot parse "2018-02-16"
晚上8点到上午10点之间 无法解析上午 ["2018-03-16 20:00:00", "2018-03-16 22:00:00"] ["2018-03-16 20:00:00", "2018-03-16 10:00:00"]
3月21号  错误解析成2019年     "2019-03-21" "2018-03-21" 

感谢@tianyuningmou 目前增加了对24节气的支持

temp = ['今年春分']
"timestamp" : "2020-03-20 00:00:00"

TODO

问题 现在版本 正确
晚上8点到上午10点之间 ["2018-03-16 20:00:00", "2018-03-16 22:00:00"] ["2018-03-16 20:00:00", "2018-03-17 10:00:00"]"

Project details


Download files

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

Files for CNSeq2TimeSpan, version 0.1.9
Filename, size File type Python version Upload date Hashes
Filename, size CNSeq2TimeSpan-0.1.9-py3-none-any.whl (30.2 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size CNSeq2TimeSpan-0.1.9.tar.gz (26.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page