|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
|
|
sentiment_classifier = pipeline("text-classification", model="isom5240grp21/finetuned_model3") |
|
|
|
|
|
keyword_extractor = pipeline("text2text-generation", model="ilsilfverskiold/bart_keywords") |
|
|
|
def main(): |
|
st.title("Hotel Review Keywords Extractor") |
|
|
|
|
|
review = st.text_area("Enter your review:") |
|
|
|
if st.button("Analyze"): |
|
if review: |
|
|
|
sentiment = sentiment_classifier(review) |
|
sentiment_label = sentiment[0]['label'] |
|
|
|
|
|
keywords = keyword_extractor(review) |
|
generated_text = keywords[0]['generated_text'] |
|
|
|
|
|
if sentiment_label == 'LABEL_0': |
|
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() |
|
|