File size: 1,107 Bytes
330f24c
 
 
 
a9858cb
330f24c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78b66d6
330f24c
78b66d6
330f24c
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()