YashJD commited on
Commit
8425aa1
·
verified ·
1 Parent(s): e54e725

Upload 2 files

Browse files
Files changed (2) hide show
  1. modb.py +44 -0
  2. requirements.txt +2 -0
modb.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import sqlite3
3
+ import pandas as pd
4
+
5
+ # Initialize SQLite database
6
+ conn = sqlite3.connect('word_classification.db')
7
+ c = conn.cursor()
8
+
9
+ # Create table if it doesn't exist
10
+ c.execute('''
11
+ CREATE TABLE IF NOT EXISTS word_classification (
12
+ word TEXT,
13
+ category TEXT
14
+ )
15
+ ''')
16
+
17
+ # Function to save word and its category
18
+ def save_word(word, category):
19
+ c.execute("INSERT INTO word_classification (word, category) VALUES (?, ?)",
20
+ (word, category))
21
+ conn.commit()
22
+
23
+ # Function to load words
24
+ def load_words():
25
+ df = pd.read_sql_query("SELECT * FROM word_classification", conn)
26
+ return df
27
+
28
+ # Streamlit UI
29
+ st.title('Word Classification')
30
+
31
+ # Input fields for word and category
32
+ word = st.text_input('Enter Word')
33
+ category = st.selectbox('Select Category', ['Theme', 'Subtheme', 'Keywords'])
34
+
35
+ if st.button('Save Word'):
36
+ save_word(word, category)
37
+ st.success(f'Word "{word}" saved under category "{category}"!')
38
+
39
+ if st.button('View All Entries'):
40
+ df = load_words()
41
+ st.dataframe(df)
42
+
43
+ # Close the database connection when the app is done
44
+ conn.close()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ streamlit
2
+ pandas