I found some code online where I can feed in a word, and find both synonyms and antonyms for this word. The code below does just that.
import nltk from nltk.corpus import wordnet #Import wordnet from the NLTK syn = list() ant = list() for synset in wordnet.synsets("fake"): for lemma in synset.lemmas(): syn.append(lemma.name()) #add the synonyms if lemma.antonyms(): #When antonyms are available, add them into the list ant.append(lemma.antonyms().name()) print('Synonyms: ' + str(syn)) print('Antonyms: ' + str(ant))
My question is, how can I choose a word, like 'and', and find all synonyms and antonyms based on comments that exist in a field in a dataframe? Here is a sample of the first 10 lines from my dataframe.
feels weird; may be a fake! package came end missing box. since itâ€™s gift i update actual fit. birkenstock amazing shoe!!!! i wish i ten pairs! delivered advertised.... shoe looks fake. second pair i had. nothing beats them. they totally fake ðŸ˜¡. they felt weird i finally noticed â€œmade germanyâ€ logo above. they also smell like glue leather. infuriating happen! i've birkenstock wearer 35 years. i wear 10 women's size ones i ordered wear big. i need size down. great brand, packaging good, dad likes them. the size clearly needs fixed others don't order bigger sizes wanted. some people don't want bigger size actually wear. false advertising. a bit loose compared birkenstocks size. still like though. very comfy