■ NLP Lab Assignment – Text Normalization
Objective: Normalize raw text using tokenization, stopword removal, stemming, and lemmatization.
■ Input Text:
Natural Language Processing (NLP) is a fascinating field of Artificial Intelligence! In this lecture, we
explored tokenization – splitting text into words or subwords. We also discussed removing
punctuation, converting to lowercase, and eliminating stop words like 'is', 'the', and 'an'. Let's
normalize text properly before passing it to a model.
■ Steps to Perform:
1. Convert all text to lowercase.
2. Remove all digits (if any).
3. Strip punctuation using Python string operations.
4. Trim extra whitespace.
5. Tokenize the text using NLTK.
6. Remove stop words using NLTK stopword list.
7. Apply stemming using PorterStemmer.
8. Apply lemmatization using WordNetLemmatizer.
9. Compare and interpret the difference between stemmed and lemmatized tokens.
■ Sample Output Snippets:
Cleaned & Tokenized:
['natural', 'language', 'processing', 'nlp', 'fascinating', 'field', 'artificial', 'intelligence', 'lecture',
'explored', 'tokenization', 'splitting', 'text', 'words', 'subwords', 'also', 'discussed', 'removing',
'punctuation', 'converting', 'lowercase', 'eliminating', 'stop', 'words', 'like', 'lets', 'normalize', 'text',
'properly', 'passing', 'model']
Stemmed Tokens:
['natur', 'languag', 'process', 'nlp', 'fascin', 'field', 'artifici', 'intellig', 'lectur', 'explor', 'token', 'split', 'text',
'word', 'subword', 'also', 'discuss', 'remov', 'punctuat', 'convert', 'lowercas', 'elimin', 'stop', 'word',
'like', 'let', 'normal', 'text', 'properli', 'pass', 'model']
Lemmatized Tokens:
['natural', 'language', 'processing', 'nlp', 'fascinating', 'field', 'artificial', 'intelligence', 'lecture',
'explored', 'tokenization', 'splitting', 'text', 'word', 'subwords', 'also', 'discussed', 'removing',
'punctuation', 'converting', 'lowercase', 'eliminating', 'stop', 'word', 'like', 'lets', 'normalize', 'text',
'properly', 'passing', 'model']