Spaces:
Sleeping
Sleeping
| 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}") | |