| import streamlit as st
|
| import sqlite3
|
| import pandas as pd
|
|
|
|
|
| conn = sqlite3.connect('word_classification.db')
|
| c = conn.cursor()
|
|
|
|
|
| c.execute('''
|
| CREATE TABLE IF NOT EXISTS word_classification (
|
| word TEXT,
|
| category TEXT
|
| )
|
| ''')
|
|
|
|
|
| def save_word(word, category):
|
| c.execute("INSERT INTO word_classification (word, category) VALUES (?, ?)",
|
| (word, category))
|
| conn.commit()
|
|
|
|
|
| def load_words():
|
| df = pd.read_sql_query("SELECT * FROM word_classification", conn)
|
| return df
|
|
|
|
|
| st.title('Word Classification')
|
|
|
|
|
| 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)
|
|
|
|
|
| conn.close()
|
|
|