Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,4 +58,20 @@ def textclassification():
|
|
| 58 |
# Calculate rating using improved function
|
| 59 |
rating = calculate_rating(sentiment, confidence)
|
| 60 |
|
| 61 |
-
# Display the
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
# Calculate rating using improved function
|
| 59 |
rating = calculate_rating(sentiment, confidence)
|
| 60 |
|
| 61 |
+
# Display the rating with stars visual
|
| 62 |
+
stars = "⭐" * rating + "☆" *
|
| 63 |
+
st.markdown(f"### Predicted Rating: {stars} ({rating}/5)")
|
| 64 |
+
|
| 65 |
+
# Question Answering
|
| 66 |
+
qa_input = {
|
| 67 |
+
'question': f'Why would this review get {rating} stars?',
|
| 68 |
+
'context': user_input
|
| 69 |
+
}
|
| 70 |
+
qa_result = qa_pipeline(qa_input)
|
| 71 |
+
st.write(f"**Key Reasons:** {qa_result['answer']}")
|
| 72 |
+
|
| 73 |
+
def main():
|
| 74 |
+
textclassification()
|
| 75 |
+
|
| 76 |
+
if __name__ == "__main__":
|
| 77 |
+
main()
|