Dagobert42 commited on
Commit
4330a70
·
1 Parent(s): 00a6def

fix result visualization

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. helpers.py +5 -2
app.py CHANGED
@@ -28,4 +28,4 @@ else:
28
  tokens = baseline_classifier(txt)
29
 
30
  st.subheader("Entity analysis:")
31
- annotated_text(annotate_sentence(sentence, tokens))
 
28
  tokens = baseline_classifier(txt)
29
 
30
  st.subheader("Entity analysis:")
31
+ annotated_text(annotate_sentence(txt, tokens))
helpers.py CHANGED
@@ -11,7 +11,6 @@ augmented_classifier = pipeline("ner",
11
 
12
  def annotate_sentence(sentence, predictions):
13
  colors = {
14
- 'null': '#bfbfbf', # Pastel gray
15
  'GeneOrGeneProduct': '#aad4aa', # Pastel green
16
  'DiseaseOrPhenotypicFeature': '#f8b400', # Pastel orange
17
  'ChemicalEntity': '#a4c2f4', # Pastel blue
@@ -24,7 +23,11 @@ def annotate_sentence(sentence, predictions):
24
  for p in predictions:
25
  if sentence[i:p['start']] != '':
26
  output.append(sentence[i:p['start']])
27
- output.append((p['word'], p['entity_group'], colors[p['entity_group']]))
 
 
 
 
28
  i = p['end']
29
  if sentence[p['end']:]:
30
  output.append(sentence[p['end']:])
 
11
 
12
  def annotate_sentence(sentence, predictions):
13
  colors = {
 
14
  'GeneOrGeneProduct': '#aad4aa', # Pastel green
15
  'DiseaseOrPhenotypicFeature': '#f8b400', # Pastel orange
16
  'ChemicalEntity': '#a4c2f4', # Pastel blue
 
23
  for p in predictions:
24
  if sentence[i:p['start']] != '':
25
  output.append(sentence[i:p['start']])
26
+ output.append(
27
+ (sentence[p['start']:p['end']], p['entity_group'], colors[p['entity_group']])
28
+ if p['entity_group'] != 'null'
29
+ else sentence[p['start']:p['end']]
30
+ )
31
  i = p['end']
32
  if sentence[p['end']:]:
33
  output.append(sentence[p['end']:])