ESE begin 27 April 2026. View Timetable
Logo

Experiment 5

Implement Rule-based Part-of-Speech (POS) Tagging.

Objective: To understand text preprocessing techniques including tokenization, stop word removal, and script validation using NLTK.


Prerequisites

Install NLTK

Open your terminal or command prompt and run: pip install nltk

Perform

  1. Open your text editor or IDE (IDLE, VS Code, etc.).
  2. Create a new file named exp2.py.
  3. Paste the code below.
  4. Run the script.

Code

import nltk
from nltk.tokenize import word_tokenize
from nltk import pos_tag

text = input("Enter your text: ")

tokenized = word_tokenize(text)

tagged = pos_tag(tokenized)

print(tokenized)
print(tagged)
ColabOpen Colab

On this page