awacke1 commited on
Commit
3a20b9a
·
1 Parent(s): 0d25e09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py CHANGED
@@ -35,8 +35,45 @@ from xml.etree import ElementTree as ET
35
 
36
  # 0 - Load USMLE dataset with answers:
37
  from datasets import load_dataset
 
 
38
  dataset = load_dataset("augtoma/usmle_step_1")
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  # 1. Constants and Top Level UI Variables
42
 
 
35
 
36
  # 0 - Load USMLE dataset with answers:
37
  from datasets import load_dataset
38
+
39
+ # 📚 Load USMLE Step 1 dataset
40
  dataset = load_dataset("augtoma/usmle_step_1")
41
 
42
+ # 🎉 Streamlit App 🎉
43
+ st.title("USMLE Step 1 Dataset Viewer")
44
+ st.write("""
45
+ 🔍 Use the search box to filter questions or use the grid to scroll through the dataset.
46
+ """)
47
+
48
+ # 👩‍🔬 Search Box
49
+ search_term = st.text_input("Search for a specific question:", "")
50
+
51
+ # 🎛 Pagination
52
+ records_per_page = 100
53
+ num_records = len(dataset['train'])
54
+ num_pages = int(num_records / records_per_page) + 1
55
+ page_number = st.select_slider("Select page:", options=list(range(1, num_pages + 1)))
56
+
57
+ # 📊 Display Data
58
+ start_idx = (page_number - 1) * records_per_page
59
+ end_idx = start_idx + records_per_page
60
+
61
+ # 🧪 Apply the Search Filter
62
+ if search_term:
63
+ filtered_data = [record for record in dataset['train'][start_idx:end_idx] if search_term.lower() in record['text'].lower()]
64
+ else:
65
+ filtered_data = dataset['train'][start_idx:end_idx]
66
+
67
+ # 🌐 Render the Grid
68
+ for record in filtered_data:
69
+ st.write(f"## Question ID: {record['id']}")
70
+ st.write(f"### Question:")
71
+ st.write(f"{record['text']}")
72
+ st.write(f"### Answer:")
73
+ st.write(f"{record['answer']}")
74
+ st.write("---")
75
+
76
+ st.write(f"😊 Total Records: {num_records} | 📄 Displaying {start_idx+1} to {min(end_idx, num_records)}")
77
 
78
  # 1. Constants and Top Level UI Variables
79