Spaces:
Sleeping
Sleeping
itachi1234
commited on
Commit
•
809a4a5
1
Parent(s):
a1a329f
Upload getvalues.py
Browse files- getvalues.py +78 -0
getvalues.py
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import re
|
2 |
+
# from listen import *
|
3 |
+
|
4 |
+
# find time in the string input provided by the user
|
5 |
+
def findTime(input):
|
6 |
+
time = re.search(r'\d{1,2}:\d{2}', input)
|
7 |
+
meridiem = re.search(r'\b(am|pm)\b', input)
|
8 |
+
if time:
|
9 |
+
tvalue = f"{time.group()} {meridiem.group()}"
|
10 |
+
return tvalue
|
11 |
+
else:
|
12 |
+
return "notime"
|
13 |
+
|
14 |
+
# find number in the string input provided by the user
|
15 |
+
def findNumber(input):
|
16 |
+
number = re.search(r'\d+', input)
|
17 |
+
if number:
|
18 |
+
return number.group()
|
19 |
+
else:
|
20 |
+
return "nonumber"
|
21 |
+
|
22 |
+
# # find date in the string input provided by the user
|
23 |
+
# def findDate(input):
|
24 |
+
# date = re.search(r'\d{1,2}/\d{1,2}/\d{4}', input)
|
25 |
+
# if date:
|
26 |
+
# return date.group()
|
27 |
+
# else:
|
28 |
+
# return "nodate"
|
29 |
+
|
30 |
+
# find month in the string input provided by the user
|
31 |
+
def findMonth(input):
|
32 |
+
month = re.search(r'\b(january|february|march|april|may|june|july|august|september|october|november|december|next month)\b', input)
|
33 |
+
if month:
|
34 |
+
return month.group()
|
35 |
+
else:
|
36 |
+
return "nomonth"
|
37 |
+
|
38 |
+
# find day in the string input provided by the user
|
39 |
+
def findDay(input):
|
40 |
+
day = re.search(r'\b(monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|day after tomorrow)\b', input)
|
41 |
+
if day:
|
42 |
+
return day.group()
|
43 |
+
else:
|
44 |
+
return "noday"
|
45 |
+
|
46 |
+
def findrepeat(input):
|
47 |
+
repeat = re.search(r'\b(daily|everyday)\b', input)
|
48 |
+
if repeat:
|
49 |
+
return repeat.group()
|
50 |
+
|
51 |
+
|
52 |
+
def getValues(query):
|
53 |
+
time = findTime(query)
|
54 |
+
num = findNumber(query)
|
55 |
+
reps = findrepeat(query)
|
56 |
+
# date = findDate(query)
|
57 |
+
month = findMonth(query)
|
58 |
+
day = findDay(query)
|
59 |
+
message = query.lower().replace(time, "").replace(num, "").replace(month, "").replace(day, "").replace("create a reminder", "").replace("remind me to", "").replace(" ", "")
|
60 |
+
return message, time, day, reps, num, month
|
61 |
+
|
62 |
+
# query = "remind me to work on my portfolio at 5:00 pm tomorrow"
|
63 |
+
# print(getValues(query))
|
64 |
+
|
65 |
+
# query = input("Enter your query : ")
|
66 |
+
# # time = findTime(query)
|
67 |
+
# # date = findDate(query)
|
68 |
+
# # day = findDay(query)
|
69 |
+
# # if day == "noday":
|
70 |
+
# # print("No day")
|
71 |
+
# # elif time == "notime":
|
72 |
+
# # print("Time not found")
|
73 |
+
# # else:
|
74 |
+
# # print("Time found")
|
75 |
+
|
76 |
+
|
77 |
+
# # query = MicExecution()
|
78 |
+
# print(findDay(query))
|