Spaces:
Sleeping
Sleeping
Upload streamlit_app.py
Browse files123456719101112131423416175619202178232491011262728293031121314153334353637383940import altair as altimport numpy as npimport pandas as pdimport streamlit as st
"""# Welcome to Streamlit!
Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [communityforums](https://discuss.streamlit.io).
In the meantime, below is an example of what you can do with just a few lines of code:"""import streamlit as stfrom transformers import pipeline
num_points = st.slider("Number of points in spiral", 1, 10000, 1100)num_turns = st.slider("Number of turns in spiral", 1, 300, 31)sentiment_analysis = pipeline("sentiment-analysis", model = "siebert/sentiment-roberta-large-english")
indices = np.linspace(0, 1, num_points)theta = 2 * np.pi * num_turns * indicesradius = indicesst.title("Sentiment Analysis")
x = radius * np.cos(theta)y = radius * np.sin(theta)rev = st.text_input("Enter a review to analyze its sentiments")analyze = st.button("Analyze")
df = pd.DataFrame({ "x": x, "y": y, "idx": indices, "rand": np.random.randn(num_points),})if analyze: result = sentiment_analysis(rev)[0]['label'] st.write(result)
st.altair_chart(alt.Chart(df, height=700, width=700) .mark_point(filled=True) .encode( x=alt.X("x", axis=None), y=alt.Y("y", axis=None), color=alt.Color("idx", legend=None, scale=alt.Scale()), size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])), ))src/streamlit_app.py+9-34