File size: 2,538 Bytes
2451ea2
 
 
 
10c452e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2451ea2
10c452e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2451ea2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import re
# from listen import *

# find time in the string input provided by the user
def find():
    def findTime(input):
        time = re.search(r'\d{1,2}:\d{2}', input)
        meridiem = re.search(r'\b(am|pm)\b', input)
        if time:
            tvalue = f"{time.group()} {meridiem.group()}"
            return tvalue
        else:
            return "notime"
        
    # find number in the string input provided by the user
    def findNumber(input):
        number = re.search(r'\d+', input)
        if number:
            return number.group()
        else:
            return "nonumber"
        
    # # find date in the string input provided by the user
    # def findDate(input):
    #     date = re.search(r'\d{1,2}/\d{1,2}/\d{4}', input)
    #     if date:
    #         return date.group()
    #     else:
    #         return "nodate"

    # find month in the string input provided by the user
    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"
        
    # find day in the string input provided by the user
    def findDay(input):
        day = re.search(r'\b(monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|day after tomorrow)\b', input)
        if day:
            return day.group()
        else:
            return "noday"
        
    def findrepeat(input):
        repeat = re.search(r'\b(daily|everyday)\b', input)
        if repeat:
            return repeat.group()
        
        
    def getValues(query):
        time = findTime(query)
        num = findNumber(query)
        reps = findrepeat(query)
        # date = findDate(query)
        month = findMonth(query)
        day = findDay(query)
        message = query.lower().replace(time, "").replace(num, "").replace(month, "").replace(day, "").replace("create a reminder", "").replace("remind me to", "").replace(" ", "")
        return message, time, day, reps, num, month
find()
        
# query = "remind me to work on my portfolio at 5:00 pm tomorrow"
# print(getValues(query))    
    
# query = input("Enter your query : ")
# # time = findTime(query)
# # date = findDate(query)
# # day = findDay(query)
# # if day == "noday":
# #     print("No day")
# # elif time == "notime":
# #         print("Time not found")
# # else:
# #     print("Time found")
        

# # query = MicExecution()
# print(findDay(query))