-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
67 lines (56 loc) · 2.3 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os.path
from datasets import load_dataset
import pandas as pd
from loguru import logger
# Function to download dataset if not exist
def download_dataset(file_path):
# Muat dataset jika belum ada
if not os.path.exists(file_path):
dataset = load_dataset("emkr-13/berita_pemilu_2024")
df = pd.DataFrame(dataset['train'])
df.to_csv(file_path, index=False)
logger.info("Dataset telah diunduh dan disimpan sebagai CSV di:", file_path)
# Path to save CSV file
file_path = "resource/dataset_pemilu_2024.csv"
# Download dataset if not exist
download_dataset(file_path)
import streamlit as st
from home import home_content
from page1 import page1_content
from page2 import page2_content
from loguru import logger
# Initialize logger
logger.add("app.log", rotation="500 MB")
def main():
try:
st.sidebar.title('Menu ')
page = st.sidebar.radio("Mau Kemana nih", ('Beranda', 'Model Klasfikasi', 'Model LDA dan LSA'))
if page == 'Beranda':
try:
logger.info("Loading Beranda page")
home_content()
logger.info("Beranda page loaded successfully")
except Exception as e:
logger.error(f"Error loading Beranda page: {e}")
st.error(f"Failed to load Beranda page {e}")
elif page == 'Model Klasfikasi':
try:
logger.info("Loading Model Klasfikasi page")
page1_content()
logger.info("Model Klasfikasi page loaded successfully")
except Exception as e:
logger.error(f"Error loading Model Klasfikasi page: {e}")
st.error(f"Failed to load Model Klasfikasi page {e}")
elif page == 'Model LDA dan LSA':
try:
logger.info("Loading Model LDA dan LSA page")
page2_content()
logger.info("Model LDA dan LSA page loaded successfully")
except Exception as e:
logger.error(f"Error loading Model LDA dan LSA page: {e}")
st.error(f"Failed to load Model LDA dan LSA page {e}")
except Exception as e:
logger.error(f"Error in main function: {e}")
st.error("An error occurred while processing your request.")
if __name__ == "__main__":
main()