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.9.tar.gz
(26.1 kB
view details)
Built Distribution
File details
Details for the file CNSeq2TimeSpan-0.1.9.tar.gz
.
File metadata
- Download URL: CNSeq2TimeSpan-0.1.9.tar.gz
- Upload date:
- Size: 26.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1f09f5a988376bda4be4ad28f6fe6ac3238fc06f2a0a0d539d9979d3fd99ffc |
|
MD5 | a4027c139a0f5e8390fdab3ffd24d0f5 |
|
BLAKE2b-256 | 48ca8c52c31807f41cddf7773902de7e9d56218f7841ed0cab3eed7cc0f42643 |
File details
Details for the file CNSeq2TimeSpan-0.1.9-py3-none-any.whl
.
File metadata
- Download URL: CNSeq2TimeSpan-0.1.9-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c61255016b0e7fd540df8f458595b910848288a6ca5fd1bece377d0f67afad3f |
|
MD5 | e2c11a723e7ac4d93fbf43a30fd556bf |
|
BLAKE2b-256 | f9830de99173d3824a7ae0d744721514238f505498428f10354c09eec39284e4 |