Spaces:
Sleeping
Sleeping
File size: 2,012 Bytes
ce333de df14808 ce333de 988a024 df14808 988a024 ce333de 988a024 ce333de 5b2bf60 ce333de |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
import re
def findTime(input)
time_regex1 = r"(1[0-2]|[1-9]):[0-5][0-9](am|AM|PM|PM|pm)"
time_search = re.search(time_regex1, input)
if time_search:
time = time_search.group(0)
return time
else:
time_regex2 = r"(1[0-2|[1-9]])\s?(am|AM|pm|PM)"
time_search = re.search(time_regex2, input)
if time_search:
time = time_search.group(0)
return time
else:
return "notime"
def findNumber(input:)
number = re.search(r'\d+', input)
if number:
return number.group()
else:
return "nonumber"
def findDate(input):
date = re.search(r'\d{1,2}/d\{1,2}/\d{4}'), input)
if date:
return date.group()
else:
return "nodate"
def findMonth(input):
month = re.search(r'\b(january|february|march|april|may|june|july|august|september|october|november|december|next month)\b', input)
if month:
return month.group()
else:
return "nomonth"
def findDay(input):
day = re.search(r'\b(monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|day after tomorrow|this week|next week|today)\b', input)
if day:
return day.group()
else:
return "noday"
def findrepeat(input):
repeat = re.search(r'\b(daliy|every day|every week|every month|every sunday|every monday|every tuesday|every wednesday|every thursday|every friday|every saturday)\b', input)
if repeat:
return repeat.group()
else:
return "no repeat"
def getValues(query):
time = findtime(query)
date= finddate(query)
rept = findrepeat(query)
day = findDay(query)
month = findMonth(query)
number = findNumber(query)
message = query.lower().replace(time,"").replace(day,"").replace(rept, "").replace("create a reminder", "").replace("remind me to", "").replace("Test", "").replace("remind", "")
return message,day,time,date, rept, month, number
|