Handle "tonight" and text containing only a date
- "tonight" is re-interpreted as PM - check is performed to check if previous word exist before accessing it to handle sentences containing only a simple datepull/1307/head
parent
7b091e9b46
commit
01b37f06eb
|
@ -379,8 +379,8 @@ def extract_datetime_en(str, currentDate=None):
|
|||
m = monthsShort.index(word)
|
||||
used += 1
|
||||
datestr = months[m]
|
||||
if wordPrev[0].isdigit() or \
|
||||
(wordPrev == "of" and wordPrevPrev[0].isdigit()):
|
||||
if wordPrev and (wordPrev[0].isdigit() or
|
||||
(wordPrev == "of" and wordPrevPrev[0].isdigit())):
|
||||
if wordPrev == "of" and wordPrevPrev[0].isdigit():
|
||||
datestr += " " + words[idx - 2]
|
||||
used += 1
|
||||
|
@ -542,6 +542,9 @@ def extract_datetime_en(str, currentDate=None):
|
|||
if nextWord == "am" or nextWord == "pm":
|
||||
remainder = nextWord
|
||||
used += 1
|
||||
elif nextWord == "tonight":
|
||||
remainder = "pm"
|
||||
used += 1
|
||||
elif wordNext == "in" and wordNextNext == "the" and \
|
||||
words[idx + 3] == "morning":
|
||||
reaminder = "am"
|
||||
|
|
Loading…
Reference in New Issue