File size: 1,419 Bytes
3fc685a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import streamlit as st 
from transformers import pipeline, AutoConfig

# Initialize the sentiment analysis pipeline
pipe = pipeline('sentiment-analysis')

# App Title
st.title("AI in Marketing | AI Driven | Text to Sentiment Analysis App | by Darren Field")
#st.text("Negative Sentiment - Example 1: The fish in the restaurant was not fresh.")
#st.text("Positive Sentiment - Example 2: The fish in the restaurant was fresh.")
#st.text("Positive Sentiments will reward you with ballons.")
#st.text("You get the idea ...try your own!")
st.text("To submit your text including your sentiment use (Ctrl + Enter) on your keyboard")

# Get the model name
model_name = pipe.model.name_or_path

# Get more detailed information about the model
config = AutoConfig.from_pretrained(model_name)

# Display model information
#st.write(f"Model Name: {model_name}")
#st.write(f"Model Type: {config.model_type}")

# Rest of your original code
text = st.text_area('Enter text including your sentiment.')

if text:
    out = pipe(text)
    st.json(out)
    
    # Check if sentiment is positive and display balloons
    if out[0]['label'] == 'POSITIVE':
        st.balloons()
        st.success("Positive sentiment detected! 🎉")
    else:
        st.info("Sentiment is not positive.")


#st.text("If you enjoyed my app, please click on the like button located at the top of")
#st.text("the page next to SentimentDector ...thank you!")