
The output shows that VBD is a verb in the past tense. To see what VBD means, we can use spacy.explain() method as shown below: print(spacy.explain(sen.tag_)) Now let's print the fine-grained POS tag for the word "hated". You can see that POS tag returned for "hated" is a "VERB" since "hated" is a verb. We will print the POS tag of the word "hated", which is actually the seventh token in the sentence. The above script simply prints the text of the sentence. Let's see this in action: print(sen.text) And finally, to get the explanation of a tag, we can use the spacy.explain() method and pass it the tag name. To obtain fine-grained POS tags, we could use the tag_ attribute. Similarly, the pos_ attribute returns the coarse-grained POS tag. For instance, to print the text of the document, the text attribute is used. The spaCy document object has several attributes that can be used to perform a variety of tasks. Next, we need to create a spaCy document that we will be using to perform parts of speech tagging. import spacyĪs usual, in the script above we import the core spaCy English model.

Let's take a very simple example of parts of speech tagging. Parts of speech tagging simply refers to assigning parts of speech to individual words in a sentence, which means that, unlike phrase matching, which is performed at the sentence or multi-word level, parts of speech tagging is performed at the token level. We will see how the spaCy library can be used to perform these two tasks.

In this article, we will study parts of speech tagging and named entity recognition in detail. In my previous article, I explained how the spaCy library can be used to perform tasks like vocabulary and phrase matching.
#Visual task psychopy example code series
This is the 4th article in my series of articles on Python for NLP.
