POS Tagging

Other topics

Remarks:

Important points to note

  • The variable word is a list of tokens.
  • Even though item i in the list word is a token, tagging single token will tag each letter of the word.
  • nltk.tag.pos_tag_ accept a
    • list of tokens -- then separate and tags its elements or
    • list of string
  • You can not get the tag for one word, instead you can put it within a list.
  • POS tag

Basic Example

import nltk
from nltk.tokenize import sent_tokenize, word_tokenize
text = 'We saw the yellow dog'
word = word_tokenize(text)
tag1 = nltk.pos_tag(word)
print(tag1)

Contributors

Topic Id: 10028

Example Ids: 30787

This site is not affiliated with any of the contributors.