Ankush05 commited on
Commit
ce333de
1 Parent(s): 8241e95

Update getValues.py

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