Spaces:
Sleeping
Sleeping
File size: 1,311 Bytes
513a379 b282894 513a379 99a7e18 513a379 b282894 513a379 99a7e18 b282894 513a379 99a7e18 513a379 b282894 513a379 b282894 513a379 |
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 |
import streamlit as st
from transformers import pipeline
# Load the sentiment analysis model
sentiment_analyzer = pipeline("sentiment-analysis", model="distilbert-base-uncased")
def main():
st.title("Know your Writing Mood")
# Text input area for the user's creative writing
writing = st.text_area("Enter your creative writing:")
if st.button("Go"):
if writing:
analyze_writing_feedback(writing)
else:
st.warning("Please enter some text.")
def analyze_writing_feedback(writing):
sentiment_result = sentiment_analyzer(writing)
sentiment_label = sentiment_result[0]['label']
feedback = generate_feedback(sentiment_label)
st.subheader("Feedback for Creative Writing:")
st.write(feedback)
def generate_feedback(sentiment_label):
if sentiment_label == "LABEL_1":
feedback = "Your writing has a positive sentiment! It evokes a sense of optimism and positivity."
elif sentiment_label == "LABEL_0":
feedback = "Your writing has a negative sentiment. It might be helpful to focus on brighter and more uplifting themes."
else:
feedback = "Your writing is neutral. Consider adding more emotional depth to enhance the impact."
return feedback
if __name__ == "__main__":
main()
|