PIERRE CUGNET
commited on
Commit
•
2847f6e
1
Parent(s):
06d9f34
feat(py): add a nice sentence
Browse files
app.py
CHANGED
@@ -51,7 +51,7 @@ def clean_text(text):
|
|
51 |
|
52 |
|
53 |
st.title('Welcome to my twitter airline sentiment analysis !', anchor='center')
|
54 |
-
airline_tweet = st.text_input('Enter your english airline tweet here:', '@AmericanAirline My flight was great! :)')
|
55 |
tokenizer = AutoTokenizer.from_pretrained('distilbert-base-uncased', num_labels=2)
|
56 |
|
57 |
encoded_input = tokenizer(
|
@@ -86,5 +86,8 @@ model.load_weights('sentiment_weights.h5')
|
|
86 |
prediction = model.predict({'input_ids' : encoded_input['input_ids'],'input_mask' : encoded_input['attention_mask']})
|
87 |
encoded_dict = {0: 'negative', 1: 'positive'}
|
88 |
|
89 |
-
|
|
|
|
|
|
|
90 |
|
|
|
51 |
|
52 |
|
53 |
st.title('Welcome to my twitter airline sentiment analysis !', anchor='center')
|
54 |
+
airline_tweet = st.text_input('Enter your english airline tweet here, press enter, and wait for the model to predict the sentiment of your review:', '@AmericanAirline My flight was great! :)')
|
55 |
tokenizer = AutoTokenizer.from_pretrained('distilbert-base-uncased', num_labels=2)
|
56 |
|
57 |
encoded_input = tokenizer(
|
|
|
86 |
prediction = model.predict({'input_ids' : encoded_input['input_ids'],'input_mask' : encoded_input['attention_mask']})
|
87 |
encoded_dict = {0: 'negative', 1: 'positive'}
|
88 |
|
89 |
+
if np.argmax(prediction) == 0:
|
90 |
+
st.write(f'Sentiment predicted : {encoded_dict[np.argmax(prediction)]}\nI\'m sorry you had a bad experience with our company :( , please accept our apologies')
|
91 |
+
else:
|
92 |
+
st.write(f'Sentiment predicted : {encoded_dict[np.argmax(prediction)]}\nGlad your flight was good ! Hope to see you soon :)')
|
93 |
|