Appendix

About

This section is included to assist the students to perform the activities in the book. It includes detailed steps that are to be performed by the students to achieve the objectives of the activities.

1. Introduction to Natural Language Processing

Activity 1: Preprocessing of Raw Text

Solution

Let's perform preprocessing on a text corpus. To implement this activity, follow these steps:

  1. Open a Jupyter notebook.
  2. Insert a new cell and add the following code to import the necessary libraries:

    import nltk

    nltk.download('punkt')

    nltk.download('averaged_perceptron_tagger')

    nltk.download('stopwords')

    nltk.download('wordnet')

    from nltk import word_tokenize

    from nltk.stem.wordnet import WordNetLemmatizer

    from nltk.corpus import stopwords ...

Get Natural Language Processing Fundamentals now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.