0 votes
in NLP using Python by
What is Parts-of-speech Tagging?

1 Answer

0 votes
by

The parts-of-speech (POS) tagging is used to assign tags to words such as nouns, adjectives, verbs, and more. The software uses the POS tagging to first read the text and then differentiate the words by tagging. The software uses algorithms for the parts-of-speech tagging. POS tagging is one of the most essential tools in Natural Language Processing. It helps in making the machine understand the meaning of a sentence.

We will look at the implementation of the POS tagging using stop words.

Let’s import the required nltk packages.

  import nltk

  from nltk.corpus import stopwords

  from nltk.tokenize import word_tokenize, sent_tokenize

  stop_words = set(stopwords.words('english'))

  txt = "Sourav, Pratyush, and Abhinav are good friends."

Tokenizing using sent_tokenize

  tokenized_text = sent_tokenize(txt)

To find punctuation and words in a string, we will use word_tokenizer and then remove the stop words.

  for n in tokenized_text:

  wordsList = nltk.word_tokenize(i)

  wordsList = [w for w in wordsList if not w instop_words]

Now, we will use the POS tagger.

  tagged_words = nltk.pos_tag(wordsList)

  print(tagged_words)

Output:

  [('Sourav', 'NNP'), ('Pratyush', 'NNP'), ('Abhinav', 'NNP'), ('good',  'JJ'), ('friends', 'NNS')]

Related questions

0 votes
asked Apr 4 in NLP using Python by SakshiSharma
0 votes
asked May 8, 2023 in NLP using Python by john ganales
...