pyunit_time package¶
Submodules¶
pyunit_time.nlptimes module¶
pyunit_time.timeunit module¶
-
class
pyunit_time.timeunit.
RangeTimeEnum
[source]¶ Bases:
object
一天大概范围时间
-
afternoon
= 15¶
-
day_break
= 3¶
-
early_morning
= 8¶
-
lateNight
= 20¶
-
midNight
= 23¶
-
morning
= 10¶
-
night
= 18¶
-
noon
= 12¶
-
-
class
pyunit_time.timeunit.
TimeUnit
(exp_time, normalizer, context)[source]¶ Bases:
object
时间解析
-
static
add_time
(cur, fore_unit: int)[source]¶ 修改日期
Parameters: - cur – 当前日期
- fore_unit – 修改属性
Returns: 修改好的日期
-
daytime
(rule, name)[source]¶ 预测一天是在什么时候
- 预测情况包括:
day_break = 3 # 黎明
early_morning = 8 # 早
morning = 10 # 上午
noon = 12 # 中午、午间
afternoon = 15 # 下午、午后
night = 18 # 晚上、傍晚
lateNight = 20 # 晚、晚间
midNight = 23 # 深夜
Parameters: - rule – 预测情况的正则
- name – 预测的名字
设置当前时间相关的时间表达式
设置时间长度相关的时间表达式
-
prefer_future
(check_time_index)[source]¶ 如果用户选项是倾向于未来时间,检查check_time_index所指的时间是否是过去的时间,如果是的话,将大一级的时间设为当前时间的+1。
如在晚上说“早上8点看书”,则识别为明天早上; 12月31日说3号买菜,则识别为明年1月的3号。
-
static