File size: 894 Bytes
650d35a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from textblob import TextBlob

# Title of the app
st.title("Text Analyzer")

# Text input from the user
user_input = st.text_area("Enter your text here:")

if user_input:
    # Word count
    word_count = len(user_input.split())
    st.write(f"**Word Count:** {word_count}")

    # Character count
    char_count = len(user_input)
    st.write(f"**Character Count:** {char_count}")

    # Sentence count
    sentence_count = user_input.count('.') + user_input.count('!') + user_input.count('?')
    st.write(f"**Sentence Count:** {sentence_count}")

    # Sentiment analysis
    analysis = TextBlob(user_input)
    sentiment = analysis.sentiment.polarity
    if sentiment > 0:
        sentiment_label = "Positive"
    elif sentiment < 0:
        sentiment_label = "Negative"
    else:
        sentiment_label = "Neutral"
    st.write(f"**Sentiment:** {sentiment_label}")