Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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[-
|
134 |
added_tokens[0] += f' {word}'
|
135 |
-
slot_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 |
|