I want to iterate through it to check if it is a word in an NLTK supported reference. Within the if statement, I want to create a new column called 'bool' and assign a true or false depending on it the reference is good or not. I wrote the following code, and for some reason it returns all falses even though it ought to be a mix. Here is the code:
from nltk.corpus import wordnet
for each in df['word']:
if not wordnet.synsets(each):
df['new'] = False
print('Not an English Word')
else:
df['new'] = True
print('English Word')
df
The first output is fine. However, the second output should have a "True" in every other row in the column 'bool' like this: 
I dont' understand why my code is not able to accomplish this.
Thanks.



Aucun commentaire:
Enregistrer un commentaire