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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
CNSeq2TimeSpan-0.1.5.tar.gz
(25.5 kB
view hashes)
Built Distribution
Close
Hashes for CNSeq2TimeSpan-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f2203aa3a94f6951a838f11a9900a772dc37033964ea243667d55ed8b0033db |
|
MD5 | 113ea3f2b6a289c0d3e66e6869c37dfc |
|
BLAKE2b-256 | 0c6a9e6a771f16b3254df4fb2633f35f5c4cf066dc190b56dc11c77b5d41edee |