Spaces:
Running
Running
def convertTotext(data_token, prediction_label): | |
prev_tag = 'O' | |
result = {} | |
temp = '' | |
for i, word in enumerate(data_token): | |
if prediction_label[i] != 'O': | |
if prev_tag == 'O' and temp != '': | |
temp = '' | |
if '##' in word: | |
temp += word.replace('##', '') | |
else: | |
temp += ' ' + word | |
else: | |
if temp != "": | |
result[prev_tag.replace("I_", "B_")] = temp.strip() | |
temp = "" | |
prev_tag = prediction_label[i] | |
return result |