Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,53 +1,11 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
-
import numpy as np
|
| 4 |
-
from annotated_text import annotated_text
|
| 5 |
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
("is", "verb", "#8ef"),
|
| 10 |
-
" some ",
|
| 11 |
-
("annotated", "adj", "#faa"),
|
| 12 |
-
("text", "noun", "#afa"),
|
| 13 |
-
" for those of ",
|
| 14 |
-
("you", "pronoun", "#fea"),
|
| 15 |
-
" who ",
|
| 16 |
-
("like", "verb", "#8ef"),
|
| 17 |
-
" this sort of ",
|
| 18 |
-
("thing", "noun", "#afa"),
|
| 19 |
-
"."
|
| 20 |
-
)
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
DATA_URL = ('https://s3-us-west-2.amazonaws.com/'
|
| 26 |
-
'streamlit-demo-data/uber-raw-data-sep14.csv.gz')
|
| 27 |
-
|
| 28 |
-
@st.cache
|
| 29 |
-
def load_data(nrows):
|
| 30 |
-
data = pd.read_csv(DATA_URL, nrows=nrows)
|
| 31 |
-
lowercase = lambda x: str(x).lower()
|
| 32 |
-
data.rename(lowercase, axis='columns', inplace=True)
|
| 33 |
-
data[DATE_COLUMN] = pd.to_datetime(data[DATE_COLUMN])
|
| 34 |
-
return data
|
| 35 |
-
|
| 36 |
-
data_load_state = st.text('Loading data...')
|
| 37 |
-
data = load_data(10000)
|
| 38 |
-
data_load_state.text("Done! (using st.cache)")
|
| 39 |
-
|
| 40 |
-
if st.checkbox('Show raw data'):
|
| 41 |
-
st.subheader('Raw data')
|
| 42 |
-
st.write(data)
|
| 43 |
-
|
| 44 |
-
st.subheader('Number of pickups by hour')
|
| 45 |
-
hist_values = np.histogram(data[DATE_COLUMN].dt.hour, bins=24, range=(0,24))[0]
|
| 46 |
-
st.bar_chart(hist_values)
|
| 47 |
-
|
| 48 |
-
# Some number in the range 0-23
|
| 49 |
-
hour_to_filter = st.slider('hour', 0, 23, 17)
|
| 50 |
-
filtered_data = data[data[DATE_COLUMN].dt.hour == hour_to_filter]
|
| 51 |
-
|
| 52 |
-
st.subheader('Map of all pickups at %s:00' % hour_to_filter)
|
| 53 |
-
st.map(filtered_data)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
pipe = pipeline('sentiment-analysis')
|
| 5 |
|
| 6 |
+
st.title("Sentiment Analysis")
|
| 7 |
+
text = st.text_area('Enter some text in the box below!')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
if text:
|
| 10 |
+
out = pipe(text)
|
| 11 |
+
st.json(out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|