Tokenize words in a list of sentences Python

后端 未结 7 1461
广开言路
广开言路 2021-02-04 06:41

i currently have a file that contains a list that is looks like

example = [\'Mary had a little lamb\' , 
           \'Jack went up the hill\' , 
           \'Ji         


        
7条回答
  •  孤街浪徒
    2021-02-04 07:15

    Break down the list "Example"

    first_split = []
    
    for i in example:
    
        first_split.append(i.split())
    

    Break down the elements of first_split list

    second_split = []
    
    for j in first_split:
    
        for k in j:
    
            second_split.append(k.split())
    

    Break down the elements of the second_split list and append it to the final list, how the coder need the output

    final_list = []
    
    for m in second_split:
    
        for n in m:
    
            if(n not in final_list):
    
                final_list.append(n)
    
    print(final_list)   
    

提交回复
热议问题