Concept

Tagging in Programming Languages

Tagging is the process of identifying and labeling Parts of Speech (POS). POS is a grammatical term that deals with the roles words play when using them together in sentences. There are eight parts of speech in English (Noun, Pronoun, Adjective, Verb, Adverb, Preposition, Conjunction, Interjection). Another POS not included in the list is Determiners, which are articles like 'a' or 'the'.

To tag a chunk of text, use word_tokenize to separate the words in the string and store them in a list. Then call

nltk.pos_tag()

on the new list of words. This will return a tuple with a word paired to their POS, such as

[('If', 'IN'), ('you', 'PRP'), ('wish', 'VBP')]

0

1

Updated 2023-04-13

References


Tags

Python Programming Language

Data Science