Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -103,17 +103,38 @@ def generate_charts(ner_output_bin: dict, ner_output_ext: dict) -> Tuple[go.Figu
|
|
103 |
entity_counts_ext = {entity: entities_ext.count(entity) for entity in set(entities_ext)}
|
104 |
ext_labels = list(entity_counts_ext.keys())
|
105 |
ext_sizes = list(entity_counts_ext.values())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
# Create pie chart for extended classification
|
108 |
-
fig1 = go.Figure(data=[go.Pie(labels=ext_labels, values=ext_sizes, textinfo='label+percent', hole=.3)])
|
109 |
-
fig1.update_layout(title_text='Extended Sequence Classification Subclasses')
|
110 |
|
111 |
# Create bar chart for binary classification
|
112 |
-
fig2 = go.Figure(data=[go.Bar(x=bin_labels, y=bin_sizes)])
|
113 |
fig2.update_layout(
|
114 |
title='Binary Sequence Classification Classes',
|
115 |
xaxis_title='Entity Type',
|
116 |
-
yaxis_title='Count'
|
|
|
117 |
)
|
118 |
|
119 |
return fig1, fig2
|
|
|
103 |
entity_counts_ext = {entity: entities_ext.count(entity) for entity in set(entities_ext)}
|
104 |
ext_labels = list(entity_counts_ext.keys())
|
105 |
ext_sizes = list(entity_counts_ext.values())
|
106 |
+
|
107 |
+
# Define color mapping
|
108 |
+
bin_color_map = {
|
109 |
+
"External": "#6ad5bcff",
|
110 |
+
"Internal": "#ee8bacff"
|
111 |
+
}
|
112 |
+
|
113 |
+
ext_color_map = {
|
114 |
+
"INTemothou": "#FF7F50", # Coral
|
115 |
+
"INTpercept": "#FF4500", # OrangeRed
|
116 |
+
"INTtime": "#FF6347", # Tomato
|
117 |
+
"INTplace": "#FFD700", # Gold
|
118 |
+
"INTevent": "#FFA500", # Orange
|
119 |
+
"EXTsemantic": "#4682B4", # SteelBlue
|
120 |
+
"EXTrepetition": "#5F9EA0", # CadetBlue
|
121 |
+
"EXTother": "#00CED1", # DarkTurquoise
|
122 |
+
}
|
123 |
+
|
124 |
+
bin_colors = [bin_color_map[label] for label in bin_labels]
|
125 |
+
ext_colors = [ext_color_map[label] for label in ext_labels]
|
126 |
|
127 |
# Create pie chart for extended classification
|
128 |
+
fig1 = go.Figure(data=[go.Pie(labels=ext_labels, values=ext_sizes, textinfo='label+percent', hole=.3, marker=dict(colors=ext_colors))])
|
129 |
+
fig1.update_layout(title_text='Extended Sequence Classification Subclasses', template='plotly_dark')
|
130 |
|
131 |
# Create bar chart for binary classification
|
132 |
+
fig2 = go.Figure(data=[go.Bar(x=bin_labels, y=bin_sizes, marker=dict(color=bin_colors))])
|
133 |
fig2.update_layout(
|
134 |
title='Binary Sequence Classification Classes',
|
135 |
xaxis_title='Entity Type',
|
136 |
+
yaxis_title='Count',
|
137 |
+
template='plotly_dark'
|
138 |
)
|
139 |
|
140 |
return fig1, fig2
|