import streamlit as st from transformers import pipeline # Load the sentiment analysis pipeline sentiment_classifier = pipeline("text-classification", model="isom5240grp21/finetuned_model3") # 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 == 'LABEL_0': # Assuming LABEL_0 indicates negative sentiment st.write(f"The hotel did bad in: {generated_text}") else: # Assuming LABEL_1 indicates positive sentiment st.write(f"The hotel did good in: {generated_text}") if __name__ == "__main__": main()