rename
This commit is contained in:
@@ -138,7 +138,7 @@ def _(WORKING_DIR, all_tags_df, mo, tag_select):
|
|||||||
|
|
||||||
# filter all_tags_df to only the document = file_dropdown.value
|
# filter all_tags_df to only the document = file_dropdown.value
|
||||||
tags_df = all_tags_df.loc[all_tags_df['tag'] == tag_select.value].copy()
|
tags_df = all_tags_df.loc[all_tags_df['tag'] == tag_select.value].copy()
|
||||||
tags_df
|
tags_df.head()
|
||||||
return (
|
return (
|
||||||
KEYWORDS_FPATH,
|
KEYWORDS_FPATH,
|
||||||
KEYWORD_FREQ_FPATH,
|
KEYWORD_FREQ_FPATH,
|
||||||
@@ -150,9 +150,9 @@ def _(WORKING_DIR, all_tags_df, mo, tag_select):
|
|||||||
|
|
||||||
|
|
||||||
@app.cell(hide_code=True)
|
@app.cell(hide_code=True)
|
||||||
def _(mo):
|
def _(KEYWORD_FREQ_FPATH, mo):
|
||||||
mo.md(r"""
|
mo.md(rf"""
|
||||||
# 4) Keyword extraction
|
# 4) Keyword extraction {'(skippable, see 4b)' if KEYWORD_FREQ_FPATH.exists() else ''}
|
||||||
""")
|
""")
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -267,7 +267,7 @@ def _(KEYWORD_FREQ_FPATH, mo, start_processing_btn):
|
|||||||
|
|
||||||
load_existing_btn = None
|
load_existing_btn = None
|
||||||
if KEYWORD_FREQ_FPATH.exists():
|
if KEYWORD_FREQ_FPATH.exists():
|
||||||
load_existing_btn = mo.ui.run_button(label=f"Load keywords from `{KEYWORD_FREQ_FPATH.name}`")
|
load_existing_btn = mo.ui.run_button(label=f"Load keywords from `{KEYWORD_FREQ_FPATH.name}`", kind='warn')
|
||||||
|
|
||||||
load_existing_btn
|
load_existing_btn
|
||||||
return (load_existing_btn,)
|
return (load_existing_btn,)
|
||||||
@@ -349,7 +349,7 @@ def _(mo, tag_select):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@app.cell
|
@app.cell(hide_code=True)
|
||||||
def _(frequency_df, min_freq_select, mo):
|
def _(frequency_df, min_freq_select, mo):
|
||||||
mo.stop('keyword' not in frequency_df.columns, "Waiting for keyword extraction to finish")
|
mo.stop('keyword' not in frequency_df.columns, "Waiting for keyword extraction to finish")
|
||||||
|
|
||||||
@@ -384,7 +384,7 @@ def _(KEYWORD_FREQ_FPATH, frequency_df, mo, remove_rows_btn, table_selection):
|
|||||||
try:
|
try:
|
||||||
frequency_df.drop(index=rows_to_drop, inplace=True, axis=0)
|
frequency_df.drop(index=rows_to_drop, inplace=True, axis=0)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
_s = mo.callout("GO TO STEP 4b) and reload data to continue refining the dataset.", kind='warn')
|
_s = mo.callout("GO BACK TO STEP 4b) and reload data to continue refining the dataset.", kind='warn')
|
||||||
else:
|
else:
|
||||||
# Save updated frequencies back to xlsx
|
# Save updated frequencies back to xlsx
|
||||||
frequency_df.to_excel(
|
frequency_df.to_excel(
|
||||||
@@ -395,7 +395,7 @@ def _(KEYWORD_FREQ_FPATH, frequency_df, mo, remove_rows_btn, table_selection):
|
|||||||
print(f"Updated keyword frequencies saved to: `{KEYWORD_FREQ_FPATH}`")
|
print(f"Updated keyword frequencies saved to: `{KEYWORD_FREQ_FPATH}`")
|
||||||
|
|
||||||
# mo.callout(f"Updated keyword frequencies saved to: `{KEYWORD_FREQ_FPATH}`", kind="success")
|
# mo.callout(f"Updated keyword frequencies saved to: `{KEYWORD_FREQ_FPATH}`", kind="success")
|
||||||
_s = mo.callout("GO TO STEP 4b) and reload data to continue refining the dataset.", kind='warn')
|
_s = mo.callout("GO BACK TO STEP 4b) and reload data to continue refining the dataset.", kind='warn')
|
||||||
|
|
||||||
_s
|
_s
|
||||||
return
|
return
|
||||||
@@ -436,11 +436,13 @@ def _(mo):
|
|||||||
canvas_size = (1200, 800)
|
canvas_size = (1200, 800)
|
||||||
|
|
||||||
logo_switch = mo.ui.switch(label="Include Chase Logo", value=False)
|
logo_switch = mo.ui.switch(label="Include Chase Logo", value=False)
|
||||||
return buffer, canvas_size, logo_switch
|
|
||||||
|
n_words = mo.ui.slider(start=10, stop=200, step=1, value=40, debounce=True, show_value=True, label="Max number of words in WordCloud")
|
||||||
|
return buffer, canvas_size, logo_switch, n_words
|
||||||
|
|
||||||
|
|
||||||
@app.cell(hide_code=True)
|
@app.cell(hide_code=True)
|
||||||
def _(logo_switch, mo):
|
def _(logo_switch, mo, n_words):
|
||||||
run_wordcloud_btn = mo.ui.run_button(label="Generate WordCloud")
|
run_wordcloud_btn = mo.ui.run_button(label="Generate WordCloud")
|
||||||
|
|
||||||
mo.vstack([
|
mo.vstack([
|
||||||
@@ -451,7 +453,7 @@ def _(logo_switch, mo):
|
|||||||
|
|
||||||
When satisfied with the result, click 'Save WordCloud to File' to save the image."""),
|
When satisfied with the result, click 'Save WordCloud to File' to save the image."""),
|
||||||
mo.md('---'),
|
mo.md('---'),
|
||||||
mo.hstack([logo_switch, run_wordcloud_btn], align='center', justify='space-around')]
|
mo.hstack([logo_switch, n_words, run_wordcloud_btn], align='center', justify='space-around')]
|
||||||
)
|
)
|
||||||
return (run_wordcloud_btn,)
|
return (run_wordcloud_btn,)
|
||||||
|
|
||||||
@@ -469,6 +471,7 @@ def _(
|
|||||||
frequency_df,
|
frequency_df,
|
||||||
logo_switch,
|
logo_switch,
|
||||||
mo,
|
mo,
|
||||||
|
n_words,
|
||||||
np,
|
np,
|
||||||
plt,
|
plt,
|
||||||
run_wordcloud_btn,
|
run_wordcloud_btn,
|
||||||
@@ -532,7 +535,7 @@ def _(
|
|||||||
width=canvas_size[0],
|
width=canvas_size[0],
|
||||||
height=canvas_size[1],
|
height=canvas_size[1],
|
||||||
max_font_size=100, # Increased font size for larger canvas
|
max_font_size=100, # Increased font size for larger canvas
|
||||||
max_words=40, # Increased word count to fill space
|
max_words=n_words.value, # Increased word count to fill space
|
||||||
color_func=blue_color_func,
|
color_func=blue_color_func,
|
||||||
mask=chase_mask, # Apply the circular mask
|
mask=chase_mask, # Apply the circular mask
|
||||||
contour_width=0,
|
contour_width=0,
|
||||||
@@ -546,7 +549,7 @@ def _(
|
|||||||
width=canvas_size[0],
|
width=canvas_size[0],
|
||||||
height=canvas_size[1],
|
height=canvas_size[1],
|
||||||
max_font_size=150, # Increased font size for larger canvas
|
max_font_size=150, # Increased font size for larger canvas
|
||||||
max_words=40, # Increased word count to fill space
|
max_words=n_words.value, # Increased word count to fill space
|
||||||
color_func=blue_color_func,
|
color_func=blue_color_func,
|
||||||
# mask=chase_mask, # Apply the circular mask
|
# mask=chase_mask, # Apply the circular mask
|
||||||
# contour_width=0,
|
# contour_width=0,
|
||||||
Reference in New Issue
Block a user