Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -96,8 +96,8 @@ def load_dictionary(file_path, file_type='json'):
|
|
96 |
df = pd.read_csv(file_path, names=['slang', 'formal'])
|
97 |
return pd.Series(df['formal'].values, index=df['slang']).to_dict()
|
98 |
|
99 |
-
ntb_dict = load_dictionary('
|
100 |
-
slang_dict = load_dictionary('
|
101 |
|
102 |
# === Utility Functions === #
|
103 |
# Fungsi untuk memperbarui file JSON dengan riwayat update
|
@@ -657,8 +657,8 @@ menu = st.sidebar.radio("Select a Feature", ["Model-Based Classification","Clust
|
|
657 |
if menu == "Model-Based Classification":
|
658 |
st.title("Model-Based Classification")
|
659 |
candidate = st.selectbox("Choose a candidate:", candidate_list)
|
660 |
-
model_path = f"
|
661 |
-
vectorizer_path = f"
|
662 |
|
663 |
# Save the selected candidate to session state
|
664 |
st.session_state['candidate'] = candidate
|
@@ -1456,12 +1456,12 @@ if menu == "Maximize Preprocessing":
|
|
1456 |
# Save Updates to File
|
1457 |
st.subheader("Save Updated Dictionaries")
|
1458 |
if st.button("Save Kamus Alay"):
|
1459 |
-
kamus_alay_path = '
|
1460 |
pd.DataFrame(list(slang_dict.items()), columns=["slang", "formal"]).to_csv(kamus_alay_path, index=False)
|
1461 |
st.success(f"Kamus Alay saved successfully to {kamus_alay_path}.")
|
1462 |
|
1463 |
if st.button("Save Kamus ntb"):
|
1464 |
-
kamus_ntb_path = '
|
1465 |
with open(kamus_ntb_path, 'w', encoding='utf-8') as f:
|
1466 |
json.dump(ntb_dict, f, indent=4)
|
1467 |
st.success(f"Kamus ntb saved successfully to {kamus_ntb_path}.")
|
|
|
96 |
df = pd.read_csv(file_path, names=['slang', 'formal'])
|
97 |
return pd.Series(df['formal'].values, index=df['slang']).to_dict()
|
98 |
|
99 |
+
ntb_dict = load_dictionary('ntb_dict.json', 'json')
|
100 |
+
slang_dict = load_dictionary('kamusalay.csv', 'csv')
|
101 |
|
102 |
# === Utility Functions === #
|
103 |
# Fungsi untuk memperbarui file JSON dengan riwayat update
|
|
|
657 |
if menu == "Model-Based Classification":
|
658 |
st.title("Model-Based Classification")
|
659 |
candidate = st.selectbox("Choose a candidate:", candidate_list)
|
660 |
+
model_path = f"best_rf_model_{candidate.replace(' ', '_').lower()}.joblib"
|
661 |
+
vectorizer_path = f"tfidf_vectorizer_{candidate.replace(' ', '_').lower()}.joblib"
|
662 |
|
663 |
# Save the selected candidate to session state
|
664 |
st.session_state['candidate'] = candidate
|
|
|
1456 |
# Save Updates to File
|
1457 |
st.subheader("Save Updated Dictionaries")
|
1458 |
if st.button("Save Kamus Alay"):
|
1459 |
+
kamus_alay_path = 'kamusalay.csv' # Adjust the path as needed
|
1460 |
pd.DataFrame(list(slang_dict.items()), columns=["slang", "formal"]).to_csv(kamus_alay_path, index=False)
|
1461 |
st.success(f"Kamus Alay saved successfully to {kamus_alay_path}.")
|
1462 |
|
1463 |
if st.button("Save Kamus ntb"):
|
1464 |
+
kamus_ntb_path = 'ntb_dict.json' # Adjust the path as needed
|
1465 |
with open(kamus_ntb_path, 'w', encoding='utf-8') as f:
|
1466 |
json.dump(ntb_dict, f, indent=4)
|
1467 |
st.success(f"Kamus ntb saved successfully to {kamus_ntb_path}.")
|