1. labels = list(map(lambda t: [label_dict[‘<start>‘]] + list(t), labels))
1 labels = list(map(lambda t: [label_dict[‘<start>‘]] + list(t), labels)) 2 3 # lambda t: [label_dict[‘<start>‘]]+list(t) 4 def func(t, label_dict): 5 return [label_dict[‘<start>‘]]+list(t) 6 # labels = list(map(, labels)) 7 labels = [func(e, label_dict) for e in labels] 8 9 # list(map由于Python3的限定,不如列表推导,要少用。 10 # list(map(func, labels))=>[func(ele) for ele in labels]
时间: 2024-10-29 14:10:10