in code/source/sentence_preprocessing.py [0:0]
def from_iob_to_io(sentences):
"""
Transforms the IOB tags in sentences (output of create_sentences_out_of_dataframe) to IO tags
:param sentences: (list of list of tuples)
:return: (list of list of tuples)
"""
clean_sentences=[]
for desc in sentences:
sublist=[]
for x in desc:
l = list(x)
tag = l[1]
if 'B-' in tag:
tag = tag.replace('B-', '')
elif 'I-' in tag:
tag = tag.replace('I-', '')
elif 'b-' in tag:
tag = tag.replace('b-', '')
elif 'i-' in tag:
tag = tag.replace('i-', '')
t = tuple([l[0], tag])
sublist.append(t)
clean_sentences.append(sublist)
return clean_sentences