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()