Dagobert42 commited on
Commit
0c62ce7
1 Parent(s): 9b720a1

small edits and comments

Browse files
Files changed (2) hide show
  1. app.py +2 -2
  2. helpers.py +12 -5
app.py CHANGED
@@ -21,8 +21,8 @@ st.subheader("Analysing challenging domains with only a handful of examples")
21
 
22
  st.write(f"""This space uses models based on [XLNet](https://huggingface.co/xlnet-base-cased) to identify medical entities in a text.
23
  The following is a random sentence from [bigbio/biored](https://huggingface.co/datasets/bigbio/biored).
24
- It was tagged by a model which was trained on 200 examples from the original dataset.
25
- It is very possible that there should be some mistakes.
26
  """)
27
 
28
  txt = sentences[session_state.counter]
 
21
 
22
  st.write(f"""This space uses models based on [XLNet](https://huggingface.co/xlnet-base-cased) to identify medical entities in a text.
23
  The following is a random sentence from [bigbio/biored](https://huggingface.co/datasets/bigbio/biored).
24
+ It was tagged by a model which was trained on just 200 examples from the original dataset.
25
+ It is very possible that there are some mistakes.
26
  """)
27
 
28
  txt = sentences[session_state.counter]
helpers.py CHANGED
@@ -11,14 +11,21 @@ def annotate_sentence(sentence, predictions):
11
  output = []
12
  i = 0
13
  for p in predictions:
 
14
  if sentence[i:p['start']] != '':
15
  output.append(sentence[i:p['start']])
16
- output.append(
17
- (sentence[p['start']:p['end']], p['entity_group'], colors[p['entity_group']])
18
- if p['entity_group'] != 'null'
19
- else sentence[p['start']:p['end']]
20
- )
 
 
 
 
21
  i = p['end']
 
 
22
  if sentence[i:] != '':
23
  output.append(sentence[p['end']:])
24
  return output
 
11
  output = []
12
  i = 0
13
  for p in predictions:
14
+ # Add initial tokens
15
  if sentence[i:p['start']] != '':
16
  output.append(sentence[i:p['start']])
17
+
18
+ # Add prediction tokens
19
+ if sentence[p['start']:p['end']] != '':
20
+ output.append(
21
+ (sentence[p['start']:p['end']], p['entity_group'], colors[p['entity_group']])
22
+ if p['entity_group'] != 'null'
23
+ else sentence[p['start']:p['end']]
24
+ )
25
+
26
  i = p['end']
27
+
28
+ # Add any trailing tokens
29
  if sentence[i:] != '':
30
  output.append(sentence[p['end']:])
31
  return output