Part of speech tagging
In many cases, NLP processing depends on determining the parts of speech of the words in the text. For example, when we want to find out the named entities that appear in a text, we need to know the parts of speech of the words. In this recipe, we will again consider NLTK and spaCy algorithms.
Getting ready
For this part, we will be using the same text of the book The Adventures of Sherlock Holmes. You can find the whole text in the book’s Github repository. For this recipe, we will need just the beginning of the book, which can be found in the file at https://github.com/PacktPublishing/Python-Natural-Language-Processing-Cookbook-Second-Edition/blob/main/data/sherlock_holmes_1.txt.
In order to do this task, you will need the NLTK and spaCy packages, described in the Technical requirements section.
We will also complete this task using the OpenAI API’s GPT model to demonstrate that it can complete it as well as spaCy and NLTK. For this...