In some cases, it can be helpful to detect the single syntactical components of a text to perform specific analyses. For example, given a sentence, we can be interested in finding the verb that represents the intent of an action. Alternatively, we could need to extract other attributes such as locations, names, and temporal dependencies. Even though this topic is quite complex and beyond the scope of this book, we wanted to provide some examples that can be immediately applied to more complex scenarios.
The first step of this process is called POS Tagging and consists of adding a syntactic identifier to each token. NLTK has a built-in model based on the Penn Treebank POS corpus, which provides a large number of standard tags for the English language (for a complete list, please check out https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html...