1. 学习
  2. /
  3. 课程
  4. /
  5. Feature Engineering for NLP in Python

Connected

练习

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.

说明 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.