nicpopovic commited on
Commit
3c93886
·
verified ·
1 Parent(s): e330964

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -76,9 +76,15 @@ def vis_network_html(relations, entities, type_colors):
76
  shape="box",
77
  color=color
78
  )
79
- # Add edges for relations
80
  for rel in relations:
81
- net.add_edge(rel["subject"], rel["object"], label=rel["predicate"], arrows="to")
 
 
 
 
 
 
82
  html = net.generate_html()
83
  html_b64 = base64.b64encode(html.encode("utf-8")).decode("utf-8")
84
  return f'<iframe src="data:text/html;base64,{html_b64}" width="100%" height="350px" frameborder="0"></iframe>'
@@ -152,7 +158,7 @@ footer { display:none !important; }
152
 
153
  # Build the Gradio interface
154
  with gr.Blocks(css=css, fill_height=True, fill_width=True) as demo:
155
- # gr.Markdown("# Data Explorer - [Dataset on Hugging Face](https://huggingface.co/datasets/nicpopovic/vital_articles_synthetic_information_extraction)")
156
  idx = gr.Number(
157
  label="Row Index",
158
  value=0,
 
76
  shape="box",
77
  color=color
78
  )
79
+ # Add edges for relations, with tooltip as description
80
  for rel in relations:
81
+ net.add_edge(
82
+ rel["subject"],
83
+ rel["object"],
84
+ label=rel["predicate"],
85
+ arrows="to",
86
+ title=rel.get("description", "") # <-- Tooltip on hover
87
+ )
88
  html = net.generate_html()
89
  html_b64 = base64.b64encode(html.encode("utf-8")).decode("utf-8")
90
  return f'<iframe src="data:text/html;base64,{html_b64}" width="100%" height="350px" frameborder="0"></iframe>'
 
158
 
159
  # Build the Gradio interface
160
  with gr.Blocks(css=css, fill_height=True, fill_width=True) as demo:
161
+ #gr.Markdown("# Data Explorer - [Dataset on Hugging Face](https://huggingface.co/datasets/nicpopovic/vital_articles_synthetic_information_extraction)")
162
  idx = gr.Number(
163
  label="Row Index",
164
  value=0,