Update app.py
Browse files
app.py
CHANGED
|
@@ -1,34 +1,10 @@
|
|
| 1 |
-
import
|
| 2 |
-
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Load the sentiment analysis pipeline
|
| 5 |
-
sentiment_classifier = pipeline("text-classification", model="isom5240grp21/finetuned_model1")
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
|
| 10 |
-
def main():
|
| 11 |
-
st.title("Hotel Review Keywords Extractor")
|
| 12 |
|
| 13 |
-
|
| 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 == 'NEGATIVE':
|
| 28 |
-
st.write(f"The hotel did bad in: {generated_text}")
|
| 29 |
-
else:
|
| 30 |
-
st.write(f"The hotel did good in: {generated_text}")
|
| 31 |
-
|
| 32 |
-
if __name__ == "__main__":
|
| 33 |
-
main()
|
| 34 |
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
|
|
|
| 2 |
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
def greet(name):
|
| 5 |
+
return "Hello " + name
|
| 6 |
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
demo.launch()
|