Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,17 @@ import plotly.graph_objects as go
|
|
24 |
from wordcloud import WordCloud
|
25 |
from PIL import Image
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
def hex_to_rgb(hex_color: str) -> tuple[int, int, int]:
|
29 |
hex_color = hex_color.lstrip('#')
|
@@ -79,16 +90,6 @@ def generate_charts(ner_output_ext: dict) -> Tuple[go.Figure, np.ndarray]:
|
|
79 |
entity_counts_ext = {entity: entities_ext.count(entity) for entity in set(entities_ext)}
|
80 |
ext_labels = list(entity_counts_ext.keys())
|
81 |
ext_sizes = list(entity_counts_ext.values())
|
82 |
-
ext_color_map = {
|
83 |
-
"INTemothou": "#FF7F50",
|
84 |
-
"INTpercept": "#FF4500",
|
85 |
-
"INTtime": "#FF6347",
|
86 |
-
"INTplace": "#FFD700",
|
87 |
-
"INTevent": "#FFA500",
|
88 |
-
"EXTsemantic": "#4682B4",
|
89 |
-
"EXTrepetition": "#5F9EA0",
|
90 |
-
"EXTother": "#00CED1",
|
91 |
-
}
|
92 |
ext_colors = [ext_color_map.get(label, "#FFFFFF") for label in ext_labels]
|
93 |
fig1 = go.Figure(data=[go.Pie(labels=ext_labels, values=ext_sizes, textinfo='label+percent', hole=.3, marker=dict(colors=ext_colors))])
|
94 |
fig1.update_layout(
|
@@ -173,16 +174,7 @@ iface = gr.Interface(
|
|
173 |
inputs=gr.Textbox(lines=5, label="Input Text", placeholder="Write about how your breakfast went or anything else that happened or might happen to you ..."),
|
174 |
outputs=[
|
175 |
gr.HighlightedText(label="Extended Sequence Classification",
|
176 |
-
ext_color_map =
|
177 |
-
"INTemothou": "#FF7F50",
|
178 |
-
"INTpercept": "#FF4500",
|
179 |
-
"INTtime": "#FF6347",
|
180 |
-
"INTplace": "#FFD700",
|
181 |
-
"INTevent": "#FFA500",
|
182 |
-
"EXTsemantic": "#4682B4",
|
183 |
-
"EXTrepetition": "#5F9EA0",
|
184 |
-
"EXTother": "#00CED1",
|
185 |
-
}
|
186 |
),
|
187 |
gr.Plot(label="Extended SeqClass Entity Distribution Pie Chart"),
|
188 |
gr.Image(label="Entity Word Cloud")
|
|
|
24 |
from wordcloud import WordCloud
|
25 |
from PIL import Image
|
26 |
|
27 |
+
ext_color_map = {
|
28 |
+
"INTemothou": "#FF7F50",
|
29 |
+
"INTpercept": "#FF4500",
|
30 |
+
"INTtime": "#FF6347",
|
31 |
+
"INTplace": "#FFD700",
|
32 |
+
"INTevent": "#FFA500",
|
33 |
+
"EXTsemantic": "#4682B4",
|
34 |
+
"EXTrepetition": "#5F9EA0",
|
35 |
+
"EXTother": "#00CED1",
|
36 |
+
}
|
37 |
+
|
38 |
|
39 |
def hex_to_rgb(hex_color: str) -> tuple[int, int, int]:
|
40 |
hex_color = hex_color.lstrip('#')
|
|
|
90 |
entity_counts_ext = {entity: entities_ext.count(entity) for entity in set(entities_ext)}
|
91 |
ext_labels = list(entity_counts_ext.keys())
|
92 |
ext_sizes = list(entity_counts_ext.values())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
ext_colors = [ext_color_map.get(label, "#FFFFFF") for label in ext_labels]
|
94 |
fig1 = go.Figure(data=[go.Pie(labels=ext_labels, values=ext_sizes, textinfo='label+percent', hole=.3, marker=dict(colors=ext_colors))])
|
95 |
fig1.update_layout(
|
|
|
174 |
inputs=gr.Textbox(lines=5, label="Input Text", placeholder="Write about how your breakfast went or anything else that happened or might happen to you ..."),
|
175 |
outputs=[
|
176 |
gr.HighlightedText(label="Extended Sequence Classification",
|
177 |
+
ext_color_map = ext_color_map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
),
|
179 |
gr.Plot(label="Extended SeqClass Entity Distribution Pie Chart"),
|
180 |
gr.Image(label="Entity Word Cloud")
|