Analysis China time in sentence
Project description
简介
Time-NLP的python3版本
python 版本https://github.com/sunfiyes/Time-NLPY
Java 版本https://github.com/shinyke/Time-NLP
功能说明
用于句子中时间词的抽取和转换
详情请见test.py
res = tn.parse(target=u'过十分钟') # target为待分析语句,timeBase为基准时间默认是当前时间
print(res)
res = tn.parse(target=u'2013年二月二十八日下午四点三十分二十九秒', timeBase='2013-02-28 16:30:29') # target为待分析语句,timeBase为基准时间默认是当前时间
print(res)
res = tn.parse(target=u'我需要大概33天2分钟四秒', timeBase='2013-02-28 16:30:29') # target为待分析语句,timeBase为基准时间默认是当前时间
print(res)
res = tn.parse(target=u'今年儿童节晚上九点一刻') # target为待分析语句,timeBase为基准时间默认是当前时间
print(res)
res = tn.parse(target=u'2个小时以前') # target为待分析语句,timeBase为基准时间默认是当前时间
print(res)
res = tn.parse(target=u'晚上8点到上午10点之间') # target为待分析语句,timeBase为基准时间默认是当前时间
print(res)
返回结果:
{"timedelta": "0 days, 0:10:00", "type": "timedelta"}
{"timestamp": "2013-02-28 16:30:29", "type": "timestamp"}
{"type": "timedelta", "timedelta": {"year": 0, "month": 1, "day": 3, "hour": 0, "minute": 2, "second": 4}}
{"timestamp": "2018-06-01 21:15:00", "type": "timestamp"}
{"error": "no time pattern could be extracted."}
{"type": "timespan", "timespan": ["2018-03-16 20:00:00", "2018-03-16 10:00:00"]}
使用方式
demo:python3 Test.py
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
chinatime-1.0.5.tar.gz
(16.2 kB
view hashes)
Built Distribution
chinatime-1.0.5-py3-none-any.whl
(38.3 kB
view hashes)
Close
Hashes for chinatime-1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11a9615ba56eb9c0adb1e3bad49f4d170555f3bdce5e72b90e8e7451fcec4f15 |
|
MD5 | 801a39a0a523572d49da317d5680a443 |
|
BLAKE2b-256 | 9fdc084b0209d1ddf2a5e8f4f54c2bf4dea11e9907a8383979cabbacf3c709dd |