DD0101 commited on
Commit
ee61aa5
1 Parent(s): 5bd29a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -127,18 +127,18 @@ def ner(text):
127
  for word, pred in zip(words, slot_preds):
128
  word = word.replace("_", " ")
129
  if pred == 'O':
130
- slot_tokens.extend([(word, None))
131
 
132
  elif pred[0] == 'I': # token with label's prefix' "I-XXX": will be combined their corresponded "B-XXX"
133
- added_tokens = list(slot_tokens[-2])
134
  added_tokens[0] += f' {word}'
135
- slot_tokens[-2] = tuple(added_tokens)
136
 
137
  elif pred[0] == 'B': # token with label's prefix "B-XXX" : remove "B-"
138
- slot_tokens.extend([(word, pred[2:]))
139
 
140
  else: # PAD or UNK tags
141
- slot_tokens.extend([(word, pred))
142
 
143
  intent_label = intent_label_lst[intent_pred]
144
 
 
127
  for word, pred in zip(words, slot_preds):
128
  word = word.replace("_", " ")
129
  if pred == 'O':
130
+ slot_tokens.extend([(word, None)])
131
 
132
  elif pred[0] == 'I': # token with label's prefix' "I-XXX": will be combined their corresponded "B-XXX"
133
+ added_tokens = list(slot_tokens[-1])
134
  added_tokens[0] += f' {word}'
135
+ slot_tokens[-1] = tuple(added_tokens)
136
 
137
  elif pred[0] == 'B': # token with label's prefix "B-XXX" : remove "B-"
138
+ slot_tokens.extend([(word, pred[2:])])
139
 
140
  else: # PAD or UNK tags
141
+ slot_tokens.extend([(word, pred)])
142
 
143
  intent_label = intent_label_lst[intent_pred]
144