AlGe commited on
Commit
5ba216a
·
verified ·
1 Parent(s): 443d088

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -13
app.py CHANGED
@@ -71,11 +71,13 @@ def process_ner(text: str, pipeline) -> dict:
71
  "entity": entity_type,
72
  "start": token['start'],
73
  "end": token['end'],
74
- "score": token['score']
 
75
  }
76
  else:
77
  current_entity['end'] = token['end']
78
  current_entity['score'] = max(current_entity['score'], token['score'])
 
79
 
80
  if current_entity is not None:
81
  entities.append(current_entity)
@@ -117,23 +119,16 @@ def generate_charts(ner_output_bin: dict, ner_output_ext: dict) -> Tuple[go.Figu
117
  }
118
 
119
  ext_color_map = {
120
- "INTemothou": "#FF7F50", # Coral
121
- "INTpercept": "#FF4500", # OrangeRed
122
- "INTtime": "#FF6347", # Tomato
123
- "INTplace": "#FFD700", # Gold
124
- "INTevent": "#FFA500", # Orange
125
- "EXTsemantic": "#4682B4", # SteelBlue
126
- "EXTrepetition": "#5F9EA0", # CadetBlue
127
- "EXTother": "#00CED1", # DarkTurquoise
128
  }
129
 
130
- bin_colors = [bin_color_map[label] for label in bin_labels]
131
- ext_colors = [ext_color_map[label] for label in ext_labels]
132
 
133
  # Create pie chart for extended classification
134
  fig1 = go.Figure(data=[go.Pie(labels=ext_labels, values=ext_sizes, textinfo='label+percent', hole=.3, marker=dict(colors=ext_colors))])
135
  fig1.update_layout(
136
- #title_text='Extended Sequence Classification Subclasses',
137
  template='plotly_dark',
138
  plot_bgcolor='rgba(0,0,0,0)',
139
  paper_bgcolor='rgba(0,0,0,0)'
@@ -142,7 +137,6 @@ def generate_charts(ner_output_bin: dict, ner_output_ext: dict) -> Tuple[go.Figu
142
  # Create bar chart for binary classification
143
  fig2 = go.Figure(data=[go.Bar(x=bin_labels, y=bin_sizes, marker=dict(color=bin_colors))])
144
  fig2.update_layout(
145
- #title='Binary Sequence Classification Classes',
146
  xaxis_title='Entity Type',
147
  yaxis_title='Count',
148
  template='plotly_dark',
 
71
  "entity": entity_type,
72
  "start": token['start'],
73
  "end": token['end'],
74
+ "score": token['score'],
75
+ "tokens": [token['word']]
76
  }
77
  else:
78
  current_entity['end'] = token['end']
79
  current_entity['score'] = max(current_entity['score'], token['score'])
80
+ current_entity['tokens'].append(token['word'])
81
 
82
  if current_entity is not None:
83
  entities.append(current_entity)
 
119
  }
120
 
121
  ext_color_map = {
122
+ "PER": "#FF7F50", # Coral
123
+ "LOC": "#4682B4", # SteelBlue
 
 
 
 
 
 
124
  }
125
 
126
+ bin_colors = [bin_color_map.get(label, "#FFFFFF") for label in bin_labels]
127
+ ext_colors = [ext_color_map.get(label, "#FFFFFF") for label in ext_labels]
128
 
129
  # Create pie chart for extended classification
130
  fig1 = go.Figure(data=[go.Pie(labels=ext_labels, values=ext_sizes, textinfo='label+percent', hole=.3, marker=dict(colors=ext_colors))])
131
  fig1.update_layout(
 
132
  template='plotly_dark',
133
  plot_bgcolor='rgba(0,0,0,0)',
134
  paper_bgcolor='rgba(0,0,0,0)'
 
137
  # Create bar chart for binary classification
138
  fig2 = go.Figure(data=[go.Bar(x=bin_labels, y=bin_sizes, marker=dict(color=bin_colors))])
139
  fig2.update_layout(
 
140
  xaxis_title='Entity Type',
141
  yaxis_title='Count',
142
  template='plotly_dark',