Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
text_classifier = pipeline("text-classification", model="nlptown/bert-base-multilingual-uncased-sentiment")
|
5 |
+
|
6 |
+
def main():
|
7 |
+
st.title("Know The Mood of Your Writing")
|
8 |
+
|
9 |
+
# Text input area for the user
|
10 |
+
text = st.text_area("Enter your text:")
|
11 |
+
|
12 |
+
if st.button("Go!"):
|
13 |
+
if text:
|
14 |
+
analyze_text_tone(text)
|
15 |
+
else:
|
16 |
+
st.warning("Please enter some text.")
|
17 |
+
|
18 |
+
def analyze_text_tone(text):
|
19 |
+
classification_result = text_classifier(text)
|
20 |
+
predicted_label = classification_result[0]['label']
|
21 |
+
|
22 |
+
st.subheader("Text Tone Analysis Result:")
|
23 |
+
st.write(f"Predicted Tone: {predicted_label}")
|
24 |
+
|
25 |
+
if __name__ == "__main__":
|
26 |
+
main()
|