Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,30 @@
|
|
1 |
import streamlit as st
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
x = st.slider('Select a value')
|
4 |
st.write(x, 'squared is', x * x)
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
+
import re
|
4 |
+
import datetime
|
5 |
+
import copy
|
6 |
+
|
7 |
+
# Absolute Date [or pieces of it]
|
8 |
+
mdy_abs_1 = re.compile('[0-9]{1,2}[-\/.][0-9]{1,2}([-\/.][0-9]{4})?', re.IGNORECASE) #12-13-2023"
|
9 |
+
mdy_abs_2 = re.compile('(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|january|february|march|april|may|june|july|august|sept|september|october|november|december)\.? ?[0-9]{1,2}(th|st|nd|rd)*,? ?([0-9]{4})?', re.IGNORECASE) # July 3
|
10 |
+
mdy_abs_3 = re.compile('[0-9]{1,2}(th|st|nd|rd)* ?(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|january|february|march|april|may|june|july|august|sept|september|october|november|december),? ?([0-9]{4})?', re.IGNORECASE)
|
11 |
+
m_abs_1 = re.compile('(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|january|february|march|april|may|june|july|august|sept|september|october|november|december)', re.IGNORECASE) # Just month
|
12 |
+
d_abs_1 = re.compile('[0-9]{1,2}(th|st|nd|rd)*', re.IGNORECASE) # Just date
|
13 |
+
|
14 |
+
# Relative Date
|
15 |
+
mdy_rel_1 = re.compile('((monday|mon)|(tuesday|tue)|(wednesday|wed)|(thursday|thu)|(friday|fri)|(saturday|sat)|(sunday|sun))([^a-z]|)]', re.IGNORECASE) # Days of week. Fully resolves.
|
16 |
+
mdy_rel_2 = re.compile('((tom)(orrow)?.?)|(today)|(tonight)|(now)|((week)(end)?)', re.IGNORECASE) # Tomorrow. Fully resolves
|
17 |
+
del_days_rel_1 = re.compile('([0-9]|( |a|the|one|two|three|four|five|six|seven|eight|nine)) ?days? ?', re.IGNORECASE) # "X days". Fully resolves
|
18 |
+
|
19 |
+
# Absolute Time
|
20 |
+
hhmm_abs_1 = re.compile('[0-9]{1,2}:?([^-\/][0-9]{0,2})? ?(am|pm|a\.m\.|p\.m\.|a m|p m|a([^a-z]|)|p([^a-z]|))', re.IGNORECASE)
|
21 |
+
hhmm_abs_2 = re.compile(' (noon|midnight)', re.IGNORECASE)
|
22 |
+
|
23 |
+
# Relative Time
|
24 |
+
del_hours_rel_1 = re.compile('([0-9]{1,2}|(|a|the|one|two|three|few|four|five|six|seven|eight|nine|ten)) ?((hour|hrs.?)|(min(ute)?))s?', re.IGNORECASE)
|
25 |
+
|
26 |
+
adverbs = re.compile('(from|after|before|next|end|this|past) ', re.IGNORECASE) # Adverbs used to resolve if multiple patterns are "hit". This leads to the "addition" problem (described on notion).
|
27 |
+
|
28 |
+
|
29 |
x = st.slider('Select a value')
|
30 |
st.write(x, 'squared is', x * x)
|