Skip to Main Content
The Natural Language Processing Workshop
book

The Natural Language Processing Workshop

by Rohan Chopra, Aniruddha M. Godbole, Nipun Sadvilkar, Muzaffar Bashir Shah, Sohom Ghosh, Dwight Gunning, Ankit Bhatia, Nagendra Nagaraj, John Bura, Sumit Kumar Raj, Tom Taulli, Ankit Verma
August 2020
Beginner to intermediate content levelBeginner to intermediate
452 pages
7h 42m
English
Packt Publishing
Content preview from The Natural Language Processing Workshop

Appendix

1. Introduction to Natural Language Processing

Activity 1.01: Preprocessing of Raw Text

Solution

Let's perform preprocessing on a text corpus. To complete 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:

    from nltk import download

    download('stopwords')

    download('wordnet')

    nltk.download('punkt')

    download('averaged_perceptron_tagger')

    from nltk import word_tokenize

    from nltk.stem.wordnet import WordNetLemmatizer

    from nltk.corpus import stopwords

    from autocorrect import Speller

    from nltk.wsd import lesk

    from nltk.tokenize import sent_tokenize

    from nltk import stem, pos_tag

    import string

  3. Read the content of file.txt and store it in a variable named sentence ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Applied AI and Natural Language Processing Workshop

The Applied AI and Natural Language Processing Workshop

Krishna Sankar, Jeffrey Jackovich, Ruze Richards
Natural Language Processing and Computational Linguistics

Natural Language Processing and Computational Linguistics

Brian Sacash, Bhargav Srinivasa-Desikan, Reddy Anil Kumar
The Applied Data Science Workshop - Second Edition

The Applied Data Science Workshop - Second Edition

Alex Galea, Paul Van Branteghem, Guillermina Bea j, Shovon Sengupta, Karen Yang

Publisher Resources

ISBN: 9781800208421Supplemental Content