Time_NLP
Time_NLP copied to clipboard
部分情况遗漏起始时间解析
temp ['明天', '上午9点', '11点'] {"type": "timespan", "timespan": ["2019-05-13 00:00:00", "2019-05-13 09:00:00"]} 2019-5-12-14-5-14 temp ['早上9点', '11点'] {"type": "timespan", "timespan": ["2019-05-13 09:00:00", "2019-05-13 11:00:00"]} 2019-5-12-14-5-14 temp ['上午9点', '11点'] {"type": "timespan", "timespan": ["2019-05-13 09:00:00", "2019-05-13 11:00:00"]}
换一个工具,JioNLP
import jionlp as jio
import time
text = '明天上午9点'
print(jio.parse_time(text, time_base=time.time()))
# {'type': 'time_point', 'definition': 'accurate', 'time': ['2021-07-27 09:00:00', '2021-07-27 09:59:59']}