|
16 | 16 |
|
17 | 17 | def get_company_df(): |
18 | 18 | csv_path = "./poligrapher/gradio_app/policy_list.csv" |
19 | | - return pd.read_csv(csv_path) |
| 19 | + df = pd.read_csv(csv_path) |
| 20 | + |
| 21 | + # Add a column for YML existence (success indicator) |
| 22 | + def yml_exists(row): |
| 23 | + company_name = str(row.get("Company Name", "")).replace(" ", "_") |
| 24 | + yml_path = f"./output/{company_name}/graph-original.full.yml" |
| 25 | + return os.path.exists(yml_path) |
| 26 | + |
| 27 | + df["YML Exists"] = df.apply(lambda row: yml_exists(row), axis=1) |
| 28 | + |
| 29 | + # For display: show checkmark or red X |
| 30 | + def yml_status(val): |
| 31 | + return "✅" if val else "⚠️" |
| 32 | + |
| 33 | + df["Status"] = df["YML Exists"].apply(yml_status) |
| 34 | + # Move Status to the leftmost column |
| 35 | + cols = df.columns.tolist() |
| 36 | + if "Status" in cols: |
| 37 | + cols.insert(0, cols.pop(cols.index("Status"))) |
| 38 | + df = df[cols] |
| 39 | + return df |
20 | 40 |
|
21 | 41 | def get_analysis_results(): |
22 | 42 | try: |
@@ -178,8 +198,19 @@ def on_submit_click(company_name, privacy_policy_url, kind): |
178 | 198 |
|
179 | 199 | with gr.Blocks() as block2: |
180 | 200 | gr.Markdown("#### Company Privacy Policy List") |
181 | | - score_btn = gr.Button("Score All") |
182 | | - company_df = gr.Dataframe(value=get_company_df(), label="Companies", interactive=False) |
| 201 | + company_df_data = get_company_df() |
| 202 | + # Count successes and errors from Status column |
| 203 | + num_success = (company_df_data["Status"] == "✅").sum() |
| 204 | + num_error = (company_df_data["Status"] != "✅").sum() |
| 205 | + gr.Markdown( |
| 206 | + f"**Status Summary:** {num_success} successful, {num_error} with incomplete YML generation." |
| 207 | + ) |
| 208 | + score_btn = gr.Button("Score All", interactive=False) |
| 209 | + # Show only relevant columns, including Status |
| 210 | + display_cols = [col for col in company_df_data.columns if col not in ["YML Exists"]] |
| 211 | + company_df = gr.Dataframe( |
| 212 | + value=company_df_data[display_cols], label="Companies", interactive=False |
| 213 | + ) |
183 | 214 | company_info = gr.Markdown("", visible=True) |
184 | 215 | png_image = gr.Image(label="Knowledge Graph", visible=True) |
185 | 216 | scoring_output = gr.Textbox(label="Scoring Results", interactive=False) |
|
0 commit comments