Hi there,
Curious if Python in Excel can lemmatize and/or stem. I have tried to import some libraries, such as ‘from nltk.stem import WordNetLemmatizer’. However, it asks me to download the library… Not sure addl Python libraries are an option for Excel?
2 Likes
At this time there are a fixed number of corpora pre-downloaded with nltk in Python in Excel.
The details are on this page.
The following corpora are pre-loaded for use with Python in Excel: brown, punkt, stopwords, treebank, vader, and wordnet2022. License: Apache v2.
Here’s an example of stemming which I mocked up in Python in Excel:
from nltk.stem import PorterStemmer, LancasterStemmer, SnowballStemmer
porter_stemmer = PorterStemmer()
lancaster_stemmer = LancasterStemmer()
snowball_stemmer = SnowballStemmer("english")
words = ["running", "ran", "easily", "fairly"]
data = []
for word in words:
data.append({
"Word": word,
"PorterStemmer": porter_stemmer.stem(word),
"LancasterStemmer": lancaster_stemmer.stem(word),
"SnowballStemmer": snowball_stemmer.stem(word)
})
df = pd.DataFrame(data)
As for lemmatizing with wordnet, I ran into an issue with my first attempt so I will explore further how to make it work.