Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
res = tn.parse(target=u'三日') # target为待分析语句,timeBase为基准时间默认是当前时间
print(res)

res = tn.parse(target=u'7点4') # target为待分析语句,timeBase为基准时间默认是当前时间
res = tn.parse(target=u'今天下午两点') # target为待分析语句,timeBase为基准时间默认是当前时间
print(res)

res = tn.parse(target=u'今年春分')
Expand Down
2 changes: 1 addition & 1 deletion TimeNormalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def __timeEx(self):
res = []
# 时间上下文: 前一个识别出来的时间会是下一个时间的上下文,用于处理:周六3点到5点这样的多个时间的识别,第二个5点应识别到是周六的。
contextTp = TimePoint()
print(self.timeBase)
# print(self.timeBase)
print('temp',temp)
for i in range(0, rpointer):
# 这里是一个类嵌套了一个类
Expand Down
14 changes: 7 additions & 7 deletions TimeUnit.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def norm_sethour(self):
self.tp.tunit[3] = int(match.group())
# print('first', self.tp.tunit[3] )
# 处理倾向于未来时间的情况
self.preferFuture(3)
# self.preferFuture(3)
self.isAllDayTime = False

# * 对关键字:早(包含早上/早晨/早间),上午,中午,午间,下午,午后,晚上,傍晚,晚间,晚,pm,PM的正确时间计算
Expand All @@ -228,7 +228,7 @@ def norm_sethour(self):
elif self.tp.tunit[3] == 0:
self.tp.tunit[3] = 12
# 处理倾向于未来时间的情况
self.preferFuture(3)
# self.preferFuture(3)
self.isAllDayTime = False

rule = u"早上|早晨|早间|晨间|今早|明早|早|清晨"
Expand All @@ -242,7 +242,7 @@ def norm_sethour(self):
self.tp.tunit[3] -= 12
elif self.tp.tunit[3] == 0:
self.tp.tunit[3] = 12
self.preferFuture(3)
# self.preferFuture(3)
self.isAllDayTime = False

rule = u"上午"
Expand All @@ -256,7 +256,7 @@ def norm_sethour(self):
elif self.tp.tunit[3] == 0:
self.tp.tunit[3] = 12
# 处理倾向于未来时间的情况
self.preferFuture(3)
# self.preferFuture(3)
self.isAllDayTime = False

rule = u"(中午)|(午间)|白天"
Expand All @@ -268,7 +268,7 @@ def norm_sethour(self):
if self.tp.tunit[3] == -1: # 增加对没有明确时间点,只写了“中午/午间”这种情况的处理
self.tp.tunit[3] = RangeTimeEnum.noon
# 处理倾向于未来时间的情况
self.preferFuture(3)
# self.preferFuture(3)
self.isAllDayTime = False

rule = u"(下午)|(午后)|(pm)|(PM)"
Expand All @@ -280,7 +280,7 @@ def norm_sethour(self):
if self.tp.tunit[3] == -1: # 增加对没有明确时间点,只写了“下午|午后”这种情况的处理
self.tp.tunit[3] = RangeTimeEnum.afternoon
# 处理倾向于未来时间的情况
self.preferFuture(3)
# self.preferFuture(3)
self.isAllDayTime = False

rule = u"晚上|夜间|夜里|今晚|明晚|晚|夜里"
Expand All @@ -294,7 +294,7 @@ def norm_sethour(self):
elif self.tp.tunit[3] == -1: # 增加对没有明确时间点,只写了“下午|午后”这种情况的处理
self.tp.tunit[3] = RangeTimeEnum.lateNight
# 处理倾向于未来时间的情况
self.preferFuture(3)
# self.preferFuture(3)
self.isAllDayTime = False

def norm_setminute(self):
Expand Down