File size: 489 Bytes
a450bc7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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