Raghuan commited on
Commit
85da700
·
verified ·
1 Parent(s): ab2ecd6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Import libraries for transformers and sentiment analysis
4
+ from transformers import pipeline
5
+
6
+ # Initialize the sentiment analysis pipeline using a pre-trained model
7
+ sentiment_analysis = pipeline("sentiment-analysis")
8
+
9
+ def main():
10
+ """
11
+ This function builds the Streamlit app for sentiment analysis.
12
+ """
13
+ # Title and description for the app
14
+ st.title("Sentiment Analysis App")
15
+ st.write("Enter a sentence for sentiment analysis.")
16
+
17
+ # Text input field
18
+ user_input = st.text_input("Enter Text Here:")
19
+
20
+ # Analyze sentiment based on user input
21
+ if user_input:
22
+ analysis = sentiment_analysis(user_input)
23
+ st.write("**Analysis:**", analysis[0]['label'])
24
+ st.write("**Confidence Score:**", analysis[0]['score'])
25
+
26
+ if __name__ == "__main__":
27
+ main()