I am trying to convert the elements of a list of list according to label map dictionary. This original list of lists looks like:
original= [['0','1','2'],
['0', '0', '0', '0', '0', '0', '0', '1', '2', '0'],
['0', '0', '1', '2', '0', '0', '0', '0']]
The label map dictionary that I want to convert the elements in the original according to:
twitter_label_map = {'0':'O', '1':'B_A', '2':'I_A'}
The desired output should be like:
desired = [['O','B_A','I_A'],
['O', 'O', 'O', 'O', 'O', 'O', 'O', 'B_A', 'I_A', 'O'],
['O', 'O', 'B_A', 'I_A', 'O', 'O', 'O', 'O']]
I have tried doing this:
desired = [[twitter_label_map[old_label] for labels_list in original] for old_label in labels_list]
However this gives me the following error:
NameError: name 'labels_list' is not defined
Thanks in advance!