Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: nlp_part_of_speech_tags_nltk.py
- # Author: Jeoi Reqi
- """
- This script performs part-of-speech tagging on a given text using NLTK.
- Requirements:
- - Python 3
- - NLTK library
- Usage:
- - Run the script, and it will print the part-of-speech tags of the provided text.
- Example:
- python speech_tags_nltk.py
- Output: Part-of-Speech Tags: [insert tags here]
- """
- from nltk import pos_tag
- from nltk.tokenize import word_tokenize
- # Sample text
- text = "Natural Language Processing is a fascinating field. It involves the use of computers to understand and process human language."
- # Tokenize the text
- words = word_tokenize(text)
- # Perform part-of-speech tagging
- pos_tags = pos_tag(words)
- print("Part-of-Speech Tags:", pos_tags)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement