awacke1 commited on
Commit
237726d
1 Parent(s): 0c346f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -57,7 +57,7 @@ data = large_data if file_option == "usmle_16.2MB.jsonl" else small_data
57
  # Top 20 healthcare terms for USMLE
58
  top_20_terms = ['Heart', 'Lung', 'Pain', 'Memory', 'Kidney', 'Diabetes', 'Cancer', 'Infection', 'Virus', 'Bacteria', 'Gastrointestinal', 'Skin', 'Blood', 'Surgery']
59
 
60
- # Create Expander and Columns UI for terms
61
  with st.expander("Search by Common Terms 📚"):
62
  cols = st.columns(4)
63
  for term in top_20_terms:
@@ -66,15 +66,17 @@ with st.expander("Search by Common Terms 📚"):
66
  filtered_data = filter_by_keyword(data, term)
67
  st.write(f"Filter on '{term}' 📊")
68
  with st.sidebar:
69
- st.dataframe(filtered_data)
70
- if not filtered_data.empty:
71
- html_blocks = []
72
  for idx, row in filtered_data.iterrows():
73
- question_text = row.get("question", "No question field")
74
- documentHTML5 = generate_html_with_textarea(question_text)
75
- html_blocks.append(documentHTML5)
76
- all_html = ''.join(html_blocks)
77
- components.html(all_html, width=1280, height=1024)
 
 
 
 
78
 
79
  # Text input for search keyword
80
  search_keyword = st.text_input("Or, enter a keyword to filter data:")
 
57
  # Top 20 healthcare terms for USMLE
58
  top_20_terms = ['Heart', 'Lung', 'Pain', 'Memory', 'Kidney', 'Diabetes', 'Cancer', 'Infection', 'Virus', 'Bacteria', 'Gastrointestinal', 'Skin', 'Blood', 'Surgery']
59
 
60
+ # Your existing expander and columns UI
61
  with st.expander("Search by Common Terms 📚"):
62
  cols = st.columns(4)
63
  for term in top_20_terms:
 
66
  filtered_data = filter_by_keyword(data, term)
67
  st.write(f"Filter on '{term}' 📊")
68
  with st.sidebar:
69
+ # Modified part: Display each row with a button
 
 
70
  for idx, row in filtered_data.iterrows():
71
+ if st.button(f"Row {idx}", key=f"row_{idx}"):
72
+ st.session_state['last_clicked_row'] = idx
73
+
74
+ # Check if there's a selected row and it's in the filtered data
75
+ if st.session_state['last_clicked_row'] in filtered_data.index:
76
+ row = filtered_data.loc[st.session_state['last_clicked_row']]
77
+ question_text = row.get("question", "No question field")
78
+ documentHTML5 = generate_html_with_textarea(question_text)
79
+ components.html(documentHTML5, width=1280, height=1024)
80
 
81
  # Text input for search keyword
82
  search_keyword = st.text_input("Or, enter a keyword to filter data:")