import streamlit as st import sqlite3 import pandas as pd # Initialize SQLite database conn = sqlite3.connect('word_classification.db') c = conn.cursor() # Create table if it doesn't exist c.execute(''' CREATE TABLE IF NOT EXISTS word_classification ( word TEXT, category TEXT ) ''') # Function to save word and its category def save_word(word, category): c.execute("INSERT INTO word_classification (word, category) VALUES (?, ?)", (word, category)) conn.commit() # Function to load words def load_words(): df = pd.read_sql_query("SELECT * FROM word_classification", conn) return df # Streamlit UI st.title('Word Classification') # Input fields for word and category word = st.text_input('Enter Word') category = st.selectbox('Select Category', ['Theme', 'Subtheme', 'Keywords']) if st.button('Save Word'): save_word(word, category) st.success(f'Word "{word}" saved under category "{category}"!') if st.button('View All Entries'): df = load_words() st.dataframe(df) # Close the database connection when the app is done conn.close()