Introduction to NLTK

NLTK - Chapter 1

NLTK Tutorial

We appreciate your patience while we actively develop and enhance our content for a better experience.

Sample Code
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from nltk.stem import PorterStemmer

def main():
    print("This program demonstrates how to use NLTK to tokenize a sentence, remove stop words, and perform basic stemming.")

    # Download required NLTK data'punkt')'stopwords')

    # Define a sample sentence
    sentence = "Become proficient in Algorithm design and enhance your Machine Learning expertise through our extensive resources."

    # Tokenize the sentence
    words = word_tokenize(sentence)

    # Remove stop words
    stop_words = set(stopwords.words('english'))
    filtered_words = [word for word in words if word.lower() not in stop_words]

    # Perform stemming using the Porter Stemmer
    stemmer = PorterStemmer()
    stemmed_words = [stemmer.stem(word) for word in filtered_words]

    # Print the results
    print(f"Original sentence: {sentence}")
    print(f"Tokenized words: {words}")
    print(f"Filtered words (stop words removed): {filtered_words}")
    print(f"Stemmed words: {stemmed_words}")

if __name__ == "__main__":