isom5240grp21 commited on
Commit
330f24c
1 Parent(s): a9c2e7f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load the sentiment analysis pipeline
5
+ sentiment_classifier = pipeline("text-classification", model="isom5240grp21/finetuned_model3")
6
+
7
+ # Load the keyword extraction pipeline
8
+ keyword_extractor = pipeline("text2text-generation", model="ilsilfverskiold/bart_keywords")
9
+
10
+ def main():
11
+ st.title("Hotel Review Keywords Extractor")
12
+
13
+ # User input for the review
14
+ review = st.text_area("Enter your review:")
15
+
16
+ if st.button("Analyze"):
17
+ if review:
18
+ # Perform sentiment analysis
19
+ sentiment = sentiment_classifier(review)
20
+ sentiment_label = sentiment[0]['label']
21
+
22
+ # Perform keyword extraction
23
+ keywords = keyword_extractor(review)
24
+ generated_text = keywords[0]['generated_text']
25
+
26
+ # Display the result based on sentiment
27
+ if sentiment_label == 'LABEL_0': # Assuming LABEL_0 indicates negative sentiment
28
+ st.write(f"The hotel did bad in: {generated_text}")
29
+ else: # Assuming LABEL_1 indicates positive sentiment
30
+ st.write(f"The hotel did good in: {generated_text}")
31
+
32
+ if __name__ == "__main__":
33
+ main()