meg-huggingface
commited on
Commit
·
c2e8ac0
1
Parent(s):
d508e46
merge
Browse files
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 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 425 |
st.markdown(
|
| 426 |
-
"
|
| 427 |
)
|
| 428 |
-
|
| 429 |
-
st.
|
| 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):
|