isom5240grp21's picture
Update app.py
78b66d6 verified
import streamlit as st
from transformers import pipeline
# Load the sentiment analysis pipeline
sentiment_classifier = pipeline("text-classification", model="isom5240grp21/finetuned_model1")
# Load the keyword extraction pipeline
keyword_extractor = pipeline("text2text-generation", model="ilsilfverskiold/bart_keywords")
def main():
st.title("Hotel Review Keywords Extractor")
# User input for the review
review = st.text_area("Enter your review:")
if st.button("Analyze"):
if review:
# Perform sentiment analysis
sentiment = sentiment_classifier(review)
sentiment_label = sentiment[0]['label']
# Perform keyword extraction
keywords = keyword_extractor(review)
generated_text = keywords[0]['generated_text']
# Display the result based on sentiment
if sentiment_label == 'NEGATIVE':
st.write(f"The hotel did bad in: {generated_text}")
else:
st.write(f"The hotel did good in: {generated_text}")
if __name__ == "__main__":
main()