From b023d44934a7dfef792e6bf0155eb3a138a92433 Mon Sep 17 00:00:00 2001 From: Luigi Maiorano Date: Wed, 10 Dec 2025 08:34:57 +0100 Subject: [PATCH] minor edits --- 02_Taguette_Post-Process.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/02_Taguette_Post-Process.py b/02_Taguette_Post-Process.py index 8ea44cc..d0170cf 100644 --- a/02_Taguette_Post-Process.py +++ b/02_Taguette_Post-Process.py @@ -79,7 +79,8 @@ def _(all_tags_df, mo): @app.cell -def _(all_tags_df, interview_select): +def _(all_tags_df, interview_select, mo): + mo.stop(not interview_select.value, mo.md("Select interview to continue")) # filter all_tags_df to only the document = file_dropdown.value df = all_tags_df.loc[all_tags_df['document'] == interview_select.value].copy() return (df,) @@ -164,7 +165,7 @@ def _(mo): @app.cell -def _(df, pd): +def _(df, mo, pd): # Expand rows that contain multiple contexts (comma-separated) expanded_rows = [] @@ -201,28 +202,29 @@ def _(df, pd): ].copy() manual_rows = sentiment_df[sentiment_df['manual_analysis']] + split_rows_editor = None + + if not manual_rows.empty: print( f"⚠️ {len(manual_rows)} rows were created from multi-context splits. " "See next cell for manual review." ) + + # Filter for rows that need review. Manual analysis and the tag starts with 'VT -' or 'CT -' + rows_to_edit = sentiment_df[ + (sentiment_df['manual_analysis']) + ] + + # Create data editor for split rows + split_rows_editor = mo.ui.data_editor( + rows_to_edit + ).form(label="Update Sentiment / Manual Flag") + else: print("✓ No multi-context rows found") - return (sentiment_df,) - -@app.cell -def _(mo, sentiment_df): - # Filter for rows that need review. Manual analysis and the tag starts with 'VT -' or 'CT -' - rows_to_edit = sentiment_df[ - (sentiment_df['manual_analysis']) - ] - - # Create data editor for split rows - split_rows_editor = mo.ui.data_editor( - rows_to_edit - ).form(label="Update Sentiment / Manual Flag") - return rows_to_edit, split_rows_editor + return rows_to_edit, sentiment_df, split_rows_editor @app.cell(hide_code=True) @@ -244,7 +246,7 @@ def _(mo, rows_to_edit, split_rows_editor): @app.cell def _(mo, split_rows_editor): # Capture the edited manual-analysis rows for validation - mo.stop(split_rows_editor.value is None, mo.md("Submit your changes.")) + mo.stop(split_rows_editor.value is None, mo.md("Submit your sentiment analysis changes before continuing.")) reviewed_manual_rows = split_rows_editor.value # Ensure all manual-analysis rows include a sentiment of -1, 0, or 1