kmanoj commited on
Commit
dae6881
1 Parent(s): ed4a54d

major update

Browse files
Files changed (1) hide show
  1. app.py +32 -14
app.py CHANGED
@@ -1,30 +1,48 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- pipe=pipeline('sentiment-analysis')
5
- # Set the title
6
- st.title("Sentiment Analysis")
7
 
8
- # Using 'form' to group input elements together
9
- with st.form("sentiment Analysis"):
 
 
 
 
10
  # Input for text to analyze sentiment
11
  text = st.text_area("Enter text for sentiment analysis:")
12
 
13
- # Add a button to analyze sentiment
14
  submit_button = st.form_submit_button("Analyze Sentiment")
15
 
16
  # Check if the form was submitted
17
  if text and submit_button:
 
18
  out = pipe(text)
19
  result = out[0] # Assuming you want the first result if multiple are returned
20
  sentiment = result["label"]
21
  score = round(result["score"], 2) # Round the score to two decimal places
22
- st.write(f"Sentiment: {sentiment}")
23
- st.write(f"Sentiment Score: {score}")
24
-
25
-
26
-
27
 
28
-
29
- # else:
30
- # st.error("Error: Something went wrong. Please try again...")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ pipe = pipeline('sentiment-analysis')
 
 
5
 
6
+ # Set the title and add introductory text
7
+ st.title("Sentiment Analysis App")
8
+ st.write("This simple app analyzes the sentiment of your text.")
9
+
10
+ # Use 'form' to group input elements together
11
+ with st.form("sentiment_form"):
12
  # Input for text to analyze sentiment
13
  text = st.text_area("Enter text for sentiment analysis:")
14
 
15
+ # Add a button with a label
16
  submit_button = st.form_submit_button("Analyze Sentiment")
17
 
18
  # Check if the form was submitted
19
  if text and submit_button:
20
+ # Analyze sentiment
21
  out = pipe(text)
22
  result = out[0] # Assuming you want the first result if multiple are returned
23
  sentiment = result["label"]
24
  score = round(result["score"], 2) # Round the score to two decimal places
 
 
 
 
 
25
 
26
+ # Display sentiment analysis results
27
+ st.header("Sentiment Analysis Result")
28
+ st.write(f"**Sentiment**: {sentiment}")
29
+ st.write(f"**Sentiment Score**: {score}")
30
+
31
+ # Add a section for instructions on how to use the app
32
+ st.header("How to Use")
33
+ st.write("1. Enter text in the text area above.")
34
+ st.write("2. Click the 'Analyze Sentiment' button to analyze the sentiment.")
35
+ st.write("3. The sentiment label and score will be displayed below.")
36
+
37
+ # Add a section with information about the sentiment analysis model
38
+ st.header("About the Model")
39
+ st.write("The sentiment analysis is performed using the Hugging Face Transformers library.")
40
+ st.write("The model used is 'nlptown/bert-base-multilingual-uncased-sentiment'.")
41
+
42
+ # Footer with a link to LinkedIn profile
43
+ st.header("Connect with Me on LinkedIn")
44
+ st.write("Feel free to connect with me on LinkedIn for any inquiries or collaborations.")
45
+ st.markdown("[LinkedIn Profile](https://www.linkedin.com/in/iam-manoj/)")
46
+
47
+ # Footer with additional information or links
48
+ st.footer("For more information, visit the [Hugging Face Transformers website](https://huggingface.co/transformers/).")