Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ classifier = pipeline("text-classification", model='Ryleeeee/CustomSentimentMode
|
|
| 6 |
|
| 7 |
# Streamlit application title and background image
|
| 8 |
st.image("./header.png", use_column_width=True)
|
| 9 |
-
st.title("Step 1: Sentiment Analysis")
|
| 10 |
|
| 11 |
st.write("Sentiment classification: positive, neutral, negative")
|
| 12 |
|
|
@@ -16,16 +16,16 @@ text = st.text_area("Enter the customer review", "")
|
|
| 16 |
# Perform sentiment analysis when the user clicks the "Classify sentiment" button
|
| 17 |
if st.button("Classify sentiment"):
|
| 18 |
# Perform sentiment analysis on the input text
|
| 19 |
-
results = classifier(text)[0]
|
| 20 |
|
| 21 |
# Display the classification result
|
| 22 |
max_score = float('-inf')
|
| 23 |
max_label = ''
|
| 24 |
|
| 25 |
for result in results:
|
| 26 |
-
if result > max_score:
|
| 27 |
-
max_score = result
|
| 28 |
-
max_label =
|
| 29 |
|
| 30 |
st.write("This review sentiment is:", max_label)
|
| 31 |
st.write("Accuracy rate is:", max_score)
|
|
@@ -33,23 +33,20 @@ if st.button("Classify sentiment"):
|
|
| 33 |
if max_label == "negative":
|
| 34 |
# Streamlit application title
|
| 35 |
st.title("Product categories of negative review")
|
| 36 |
-
st.write("Product classification of this negative review: smartTv, books, mobile, mobile accessories
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
# Perform product classification analysis when the user clicks the "Classify product" button
|
| 39 |
if st.button("Classify product"):
|
| 40 |
# Perform product classification analysis on the input text
|
| 41 |
-
results_1 =
|
| 42 |
|
| 43 |
# Display the classification result
|
| 44 |
max_score_1 = float('-inf')
|
| 45 |
max_label_1 = ''
|
| 46 |
|
| 47 |
for result_1 in results_1:
|
| 48 |
-
if result_1 > max_score_1:
|
| 49 |
-
max_score_1
|
| 50 |
-
max_label_1 = classifier.model.config.id2label_1[results_1.index(result_1)]
|
| 51 |
-
|
| 52 |
-
st.write("This negative review blongs to:", max_label_1)
|
| 53 |
-
st.write("Accuracy rate is:", max_score_1)
|
| 54 |
-
|
| 55 |
-
|
|
|
|
| 6 |
|
| 7 |
# Streamlit application title and background image
|
| 8 |
st.image("./header.png", use_column_width=True)
|
| 9 |
+
st.title("Step 1: Sentiment Analysis", use_column_width=True)
|
| 10 |
|
| 11 |
st.write("Sentiment classification: positive, neutral, negative")
|
| 12 |
|
|
|
|
| 16 |
# Perform sentiment analysis when the user clicks the "Classify sentiment" button
|
| 17 |
if st.button("Classify sentiment"):
|
| 18 |
# Perform sentiment analysis on the input text
|
| 19 |
+
results = classifier(text)[0]
|
| 20 |
|
| 21 |
# Display the classification result
|
| 22 |
max_score = float('-inf')
|
| 23 |
max_label = ''
|
| 24 |
|
| 25 |
for result in results:
|
| 26 |
+
if result['score'] > max_score:
|
| 27 |
+
max_score = result['score']
|
| 28 |
+
max_label = result['label']
|
| 29 |
|
| 30 |
st.write("This review sentiment is:", max_label)
|
| 31 |
st.write("Accuracy rate is:", max_score)
|
|
|
|
| 33 |
if max_label == "negative":
|
| 34 |
# Streamlit application title
|
| 35 |
st.title("Product categories of negative review")
|
| 36 |
+
st.write("Product classification of this negative review: smartTv, books, mobile, mobile accessories and refrigerators")
|
| 37 |
+
|
| 38 |
+
# Load the product classification model pipeline
|
| 39 |
+
product_classifier = pipeline("text-classification", model='model_name', return_all_scores=True)
|
| 40 |
|
| 41 |
# Perform product classification analysis when the user clicks the "Classify product" button
|
| 42 |
if st.button("Classify product"):
|
| 43 |
# Perform product classification analysis on the input text
|
| 44 |
+
results_1 = product_classifier(text)
|
| 45 |
|
| 46 |
# Display the classification result
|
| 47 |
max_score_1 = float('-inf')
|
| 48 |
max_label_1 = ''
|
| 49 |
|
| 50 |
for result_1 in results_1:
|
| 51 |
+
if result_1['score'] > max_score_1:
|
| 52 |
+
max_score_1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|