# import libraries import streamlit as st import predict import logging # Logging configuration logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') # Load necessary components df = predict.load_dataset() model, tokenizer = predict.load_model_and_tokenizer() if df is not None and model is not None and tokenizer is not None: # Preprocess dataset and prepare stopwords and stemmer manual_stopwords = ["di", "ke", "dari", "yang", "dan", "atau", "dengan", "untuk", "ini", "itu", "aja", "saja", "lah", "bri", "brimo", "aplikasi", "rekening", "coba", "yg", "ke", "untuk", "nya", "saya", "dia", "dan", "sangat", "video", "login", "apk", "jadi", "akun", "malah", "uang", "banget", "dalam", "atm", "padahal"] stop_words = set(predict.stopwords.words('indonesian')) stop_words.update(manual_stopwords) factory = predict.StemmerFactory() stemmer = factory.create_stemmer() df['label'] = df['score'].apply(predict.map_labels) navigation = st.sidebar.selectbox('Choose Page:', ('predictor')) if navigation == 'predictor': predict.run(model, tokenizer, stop_words, stemmer) # elif navigation == 'eda': # eda.run() else: if df is None: logging.error("Failed to load dataset.") st.error("Failed to load the dataset. Please check the dataset file.") if model is None or tokenizer is None: logging.error("Failed to load model or tokenizer.") st.error("Failed to load the model or tokenizer. Please check the model file.")