You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import nltkfrom nltk.tokenize import word_tokenizefrom nltk.stem import PorterStemmer, WordNetLemmatizerfrom nltk.corpus import wordnet# Download necessary NLTK resources (only required once)nltk.download('punkt')nltk.download('wordnet')# Sample texttext = "Tokenization is an important NLP technique. It involves breaking down text into smaller units, such as words or subwords."# Tokenizationtokens = word_tokenize(text)print("Tokens:", tokens)# Stemmingstemmer = PorterStemmer()stemmed_words = [stemmer.stem(token) for token in tokens]print("Stemmed words:", stemmed_words)# Lemmatizationlemmatizer = WordNetLemmatizer()lemmatized_words = [lemmatizer.lemmatize(token, wordnet.VERB) for token in tokens]print("Lemmatized words:", lemmatized_words)