import nltk
from nltk.stem import PorterStemmer

# Initialize a PorterStemmer
stemmer = PorterStemmer()

# Sample words
words = ["swimming", "ran", "runs", "easily", "fairly", "fairness"]

# Stemming
stemmed_words = [stemmer.stem(word) for word in words]

#Print stemmed words
print("Original Words:", words)
print("Stemmed Words:", stemmed_words)



from nltk.stem import WordNetLemmatizer

# Initialize a WordNetLemmatizer
lemmatizer = WordNetLemmatizer()

# Sample words
words = ["stopped", "swimming", "stemmed", "being", "are", "processing"]

# Lemmatization
lemmatized_words = [lemmatizer.lemmatize(word) for word in words]

# Print lemmatized words
print("Original Words:", words)
print("Lemmatized Words:", lemmatized_words)




import nltk
# Sample text
text = "NLTK is a leading platform for building Python programs to work with human language data."

# Tokenize the text into words
words = nltk.word_tokenize(text)

# Perform POS tagging
pos_tags = nltk.pos_tag(words)

# Print POS tagged words
print("POS Tagged Words:")
print(pos_tags)