naufalnashif
commited on
Commit
·
944ad8c
1
Parent(s):
f0811c9
Update app.py
Browse files
app.py
CHANGED
@@ -108,7 +108,7 @@ def select_sentiment_model(selected_model):
|
|
108 |
|
109 |
# Fungsi untuk prediksi sentimen
|
110 |
@st.cache_data
|
111 |
-
def predict_sentiment(text,
|
112 |
# Tahap-1: Membersihkan dan normalisasi teks
|
113 |
cleaned_text = clean_text(text)
|
114 |
norm_slang_text = normalize_slang(cleaned_text, slang_dict)
|
@@ -173,7 +173,7 @@ else:
|
|
173 |
# Analisis sentimen
|
174 |
results = []
|
175 |
analisis = False
|
176 |
-
if input_option == "Teks Manual" and user_input:
|
177 |
# Pisahkan teks yang dimasukkan pengguna menjadi baris-baris terpisah
|
178 |
user_texts = user_input.split('\n')
|
179 |
for text in user_texts:
|
@@ -184,7 +184,7 @@ if input_option == "Teks Manual" and user_input:
|
|
184 |
results.append((text, cleaned_text, norm_slang_text, sentiment_label, emoticon))
|
185 |
analisis = True
|
186 |
|
187 |
-
elif input_option == "Unggah Berkas XLSX" and uploaded_file is not None:
|
188 |
if 'Text' in df.columns:
|
189 |
for text in texts:
|
190 |
sentiment_label = predict_sentiment(text, sentiment_model, tfidf_vectorizer, lookp_dict)
|
@@ -196,8 +196,10 @@ elif input_option == "Unggah Berkas XLSX" and uploaded_file is not None:
|
|
196 |
|
197 |
else:
|
198 |
st.warning("Berkas XLSX harus memiliki kolom bernama 'Text' untuk analisis sentimen.")
|
|
|
|
|
199 |
st.info('Tekan "Analysis" kemabli jika tampilan menghilang', icon = 'ℹ️')
|
200 |
-
if results and analisis == True
|
201 |
# Membagi tampilan menjadi dua kolom
|
202 |
columns = st.columns(2)
|
203 |
|
|
|
108 |
|
109 |
# Fungsi untuk prediksi sentimen
|
110 |
@st.cache_data
|
111 |
+
def predict_sentiment(text, _model, tfidf_vectorizer, slang_dict):
|
112 |
# Tahap-1: Membersihkan dan normalisasi teks
|
113 |
cleaned_text = clean_text(text)
|
114 |
norm_slang_text = normalize_slang(cleaned_text, slang_dict)
|
|
|
173 |
# Analisis sentimen
|
174 |
results = []
|
175 |
analisis = False
|
176 |
+
if st.button("Analysis") and input_option == "Teks Manual" and user_input:
|
177 |
# Pisahkan teks yang dimasukkan pengguna menjadi baris-baris terpisah
|
178 |
user_texts = user_input.split('\n')
|
179 |
for text in user_texts:
|
|
|
184 |
results.append((text, cleaned_text, norm_slang_text, sentiment_label, emoticon))
|
185 |
analisis = True
|
186 |
|
187 |
+
elif st.button("Analysis") and input_option == "Unggah Berkas XLSX" and uploaded_file is not None:
|
188 |
if 'Text' in df.columns:
|
189 |
for text in texts:
|
190 |
sentiment_label = predict_sentiment(text, sentiment_model, tfidf_vectorizer, lookp_dict)
|
|
|
196 |
|
197 |
else:
|
198 |
st.warning("Berkas XLSX harus memiliki kolom bernama 'Text' untuk analisis sentimen.")
|
199 |
+
|
200 |
+
|
201 |
st.info('Tekan "Analysis" kemabli jika tampilan menghilang', icon = 'ℹ️')
|
202 |
+
if results and analisis == True:
|
203 |
# Membagi tampilan menjadi dua kolom
|
204 |
columns = st.columns(2)
|
205 |
|