'ValueErrror unpack in Word2vec

I have stopwords and list1 and want to get list 2 after removing stopwords

stopwords= [" I ", " in ", " a ", " m ", " of ", " It ", " is "," all ",  " about ", " you ", " to ", " at "]

list1 = ["I order food in a restaurant","I m fan of soccer","It is all about passion","you want to stay at home"]

list2 = [["order" "food","restaurant"],["fan","soccer"],["passion"],["want","stay","home"]


Solution 1:[1]

I don't know what your subject has to do with the code you're presenting, but here's a way to accomplish what you're asking for:

stopwords= [" I ", " in ", " a ", " m ", " of ", " It ", " is "," all ", " about ", " you ", " to ", " at "]

list1 = ["I order food in a restaurant","I m fan of soccer","It is all about passion","you want to stay at home"]

# remove spaces and lowerize each stop word
stopwords = [w.lower().strip() for w in stopwords]

# process each sentence, and for each sentence, each word
list2 = [[word for word in words.split() if word.lower() not in stopwords] for words in list1]

print(list2)

Result:

[['order', 'food', 'restaurant'], ['fan', 'soccer'], ['passion'], ['want', 'stay', 'home']]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CryptoFool