meg-huggingface commited on
Commit
c2e8ac0
β€’
1 Parent(s): d508e46
Files changed (1) hide show
  1. data_measurements/streamlit_utils.py +27 -24
data_measurements/streamlit_utils.py CHANGED
@@ -390,7 +390,7 @@ def expander_zipf(z, zipf_fig, column_id):
390
  if z.xmin > 5:
391
  st.markdown(xmin_warning)
392
  except:
393
- st.write("Under construction!")
394
 
395
 
396
  ### Finally finally finally, show nPMI stuff.
@@ -404,31 +404,34 @@ def npmi_widget(npmi_stats, min_vocab, column_id):
404
  :return:
405
  """
406
  with st.expander(f"Word Association{column_id}: nPMI", expanded=False):
407
- if len(npmi_stats.available_terms) > 0:
408
- expander_npmi_description(min_vocab)
409
- st.markdown("-----")
410
- term1 = st.selectbox(
411
- f"What is the first term you want to select?{column_id}",
412
- npmi_stats.available_terms,
413
- )
414
- term2 = st.selectbox(
415
- f"What is the second term you want to select?{column_id}",
416
- reversed(npmi_stats.available_terms),
417
- )
418
- # We calculate/grab nPMI data based on a canonical (alphabetic)
419
- # subgroup ordering.
420
- subgroup_pair = sorted([term1, term2])
421
- try:
422
- joint_npmi_df = npmi_stats.load_or_prepare_joint_npmi(subgroup_pair)
423
- npmi_show(joint_npmi_df)
424
- except KeyError:
 
 
 
 
 
425
  st.markdown(
426
- "**WARNING!** The nPMI for these terms has not been pre-computed, please re-run caching."
427
  )
428
- else:
429
- st.markdown(
430
- "No words found co-occurring with both of the selected identity terms."
431
- )
432
 
433
 
434
  def npmi_show(paired_results):
 
390
  if z.xmin > 5:
391
  st.markdown(xmin_warning)
392
  except:
393
+ st.write("Under construction! 😱 🚧")
394
 
395
 
396
  ### Finally finally finally, show nPMI stuff.
 
404
  :return:
405
  """
406
  with st.expander(f"Word Association{column_id}: nPMI", expanded=False):
407
+ try:
408
+ if len(npmi_stats.available_terms) > 0:
409
+ expander_npmi_description(min_vocab)
410
+ st.markdown("-----")
411
+ term1 = st.selectbox(
412
+ f"What is the first term you want to select?{column_id}",
413
+ npmi_stats.available_terms,
414
+ )
415
+ term2 = st.selectbox(
416
+ f"What is the second term you want to select?{column_id}",
417
+ reversed(npmi_stats.available_terms),
418
+ )
419
+ # We calculate/grab nPMI data based on a canonical (alphabetic)
420
+ # subgroup ordering.
421
+ subgroup_pair = sorted([term1, term2])
422
+ try:
423
+ joint_npmi_df = npmi_stats.load_or_prepare_joint_npmi(subgroup_pair)
424
+ npmi_show(joint_npmi_df)
425
+ except KeyError:
426
+ st.markdown(
427
+ "**WARNING!** The nPMI for these terms has not been pre-computed, please re-run caching."
428
+ )
429
+ else:
430
  st.markdown(
431
+ "No words found co-occurring with both of the selected identity terms."
432
  )
433
+ except:
434
+ st.write("Under construction! 😱 🚧")
 
 
435
 
436
 
437
  def npmi_show(paired_results):