cattana commited on
Commit
8ec8cd1
1 Parent(s): 3b45e52
Files changed (3) hide show
  1. app.py +31 -0
  2. cliff_gradio.jsonl +0 -0
  3. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import spacy
3
+ from spacy import displacy
4
+ import pandas as pd
5
+
6
+ df = pd.read_json("cliff_gradio.jsonl", orient="index")
7
+ colors = {"ext": "#aa9cfc", "int": "#ff6961", "wor": "#7aecec"}
8
+ options = {"colors": colors}
9
+
10
+ nlp = spacy.blank("en")
11
+
12
+ def viz(topic_id):
13
+ row = df.loc[topic_id]
14
+ summary = row["summary"]
15
+ labels = row["labels"]
16
+ score = row["score"]
17
+ ex = [{"text": summary,
18
+ "ents": [{"start": token.idx, "end": token.idx + token.__len__() + 1, "label": label[:3]} for token, label in zip(nlp(summary), labels) if label != "correct"],
19
+ "title": None}]
20
+ return displacy.render(ex, style="ent", manual=True, options=options), score
21
+
22
+
23
+
24
+
25
+ demo = gr.Interface(fn=viz,
26
+ inputs=[gr.Dropdown(cliff["id"].tolist(), label="Select Topic Id")],
27
+ outputs=["html", "number"])
28
+
29
+
30
+
31
+ demo.launch()
cliff_gradio.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ spacy
2
+ pandas