Session Ready
Exercise

Counting nouns in a piece of text

In this exercise, we will write two functions, nouns() and proper_nouns() that will count the number of other nouns and proper nouns in a piece of text respectively.

These functions will take in a piece of text and generate a list containing the POS tags for each word. It will then return the number of proper nouns/other nouns that the text contains. We will use these functions in the next exercise to generate interesting insights about fake news.

The en_core_web_sm model has already been loaded as nlp in this exercise.

Instructions 1/2
undefined XP
  • 1

    Using the list count method, count the number of proper nouns (annotated as PROPN) in the pos list.

    • 2

      Using the list count method, count the number of other nouns (annotated as NOUN) in the pos list.