Skip to content

Commit ecbbf70

Browse files
committed
feat(app): Enhance company DataFrame with YML existence check and status summary
1 parent 6840dde commit ecbbf70

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

current_env.yml

Whitespace-only changes.

environment.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
- spacy-model-en_core_web_md=3.8.0
1111
- regex=2024.11.6
1212
- psycopg2=2.9.10
13+
- lxml=6.0.0
1314
- pip
1415
- pip:
1516
- gradio==5.38.0
@@ -26,3 +27,4 @@ dependencies:
2627
- anytree==2.13.0
2728
- Unidecode==1.3.6
2829
- httpx==0.24.1
30+
- spacy-transformers==1.3.9

poligrapher/gradio_app/app.py

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,27 @@
1616

1717
def get_company_df():
1818
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
2040

2141
def get_analysis_results():
2242
try:
@@ -178,8 +198,19 @@ def on_submit_click(company_name, privacy_policy_url, kind):
178198

179199
with gr.Blocks() as block2:
180200
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+
)
183214
company_info = gr.Markdown("", visible=True)
184215
png_image = gr.Image(label="Knowledge Graph", visible=True)
185216
scoring_output = gr.Textbox(label="Scoring Results", interactive=False)

0 commit comments

Comments
 (0)