Playing with Grammar
Grammar is one of the main building blocks of language. Each human language, and programming language for that matter, has a set of rules that every person speaking it must follow, otherwise risking not being understood. These grammatical rules can be uncovered using NLP and are useful for extracting data from sentences. For example, using information about the grammatical structure of text, we can parse out subjects, objects, and relations between different entities.
In this chapter, you will learn how to use different packages to reveal the grammatical structure of words and sentences, as well as extract certain parts of sentences. These are the topics covered in this chapter:
- Counting nouns – plural and singular nouns
- Getting the dependency parse
- Extracting noun chunks
- Extracting the subjects and objects of the sentence
- Finding patterns in text using grammatical information