From 01b37f06eb1a6a24ab007c7c5e17dd3b2b85bce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Forslund?= Date: Tue, 12 Dec 2017 08:35:13 +0100 Subject: [PATCH] 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 date --- mycroft/util/parse.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mycroft/util/parse.py b/mycroft/util/parse.py index f78bcc46df..d7d75d1ee0 100644 --- a/mycroft/util/parse.py +++ b/mycroft/util/parse.py @@ -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"